Create and Debug Azure Function using Visual Studio 2017 – Part 1

Ahamed Fazil Buhari
 
Senior Developer
October 30, 2018
 
Rate this article
 
Views
2246

Hello Everyone,

In this article we will see how to create Azure function from VS 2017, its necessary to have basic knowledge on Azure Function before getting deep into this article. And I split this article into two parts since it involves many steps.

Before creating Azure Function from VS, it’s necessary to install couple of package to create and debug azure function, for debugging we need Azure CLI to be installed in your local machine. You can download Azure CLI from here and I installed Azure extension which helps in creating and publishing Azure Function. You can go to Extensions and Updates window from Tools in top menu bar.

clip_image002

If you are using VS 2015 and it doesn’t have Azure Function extension then you can refer this link to get Azure Function project in VS 2015. Ok, let’s get into the topic,

Step 1: Open VS 2017 and just like normal project creation, click on New -> Azure Function (under Cloud).

clip_image004

Step 2: Assigning Storage Account. I do have my own VisualStudio Enterprise subscription and Azure account. So I refer to my Azure storage account, if you don’t have storage account then you can go ahead with Storage Emulator(The Microsoft Azure storage emulator provides a local environment that emulates the Azure Blob, Queue, and Table services for development purposes – ref Microsoft) .

clip_image005

Step 3: I have resource group my-azure-fn and azure storage account as myazurefn99330 which was created already from azure portal. You can skip step 4 if you don’t want to create Azure Storage Account. (I don’t want to create another storage account because I already have one. Also it’s better to create azure storage account from https://portal.azure than creating from VS.)

)clip_image007

Step 4: In Create a Storage Account dialog, we need to provide name of the account name subscription, resource group, location(near to your geographic location) and Account Type( it is important because it decides your storage account durability and replication of data for high availability – this will take separate topic, so I provided Microsoft link to know more about Azure Storage Account Type ). Click on Create, it will take few minutes to create storage account in Azure.

clip_image009

Step 5: Access rights option is to set authentication rights to access your azure function, usually it will be authenticated using key value. If you do not want any authentication then anonyms (not good for production) should be selected.

clip_image010

Step 6: Select Http trigger as template and click on OK. It will create class file, to check whether it works fine, keep a debug pointer and press F5. Azure CLI will open automatically and it will listen through localhost.

clip_image012

And when we access the localhost:7071 from the browser, it will call the Azure function, because our azure function is waiting for Http trigger,

clip_image013

In the next article we will see how to publish Azure Function from VS2017, to be continued…

Happy Coding

Ahamed

Author Info

Ahamed Fazil Buhari
 
Senior Developer
 
Rate this article
 
Ahamed is a Senior Developer and he has very good experience in the field of Microsoft Technologies, especially SharePoint, Azure, M365, SPFx, .NET and client side scripting - JavaScript, TypeScript, ...read more
 

Leave a comment