Azure Function - Deployment

Azure Function - Deployment

By Frédéric Schmidt
Published in Microsoft Azure
September 10, 2020
4 min read


As I mentioned in the post about the demonstration of the creation and development of the code of an azure function here is the time to publish it in our subscription Azure.

But before that, we will have to create all the resources that will be used for the proper functioning of the DMP calculation function.

In this post, I decided to perform all the online actions with the Azure CLI. In another post, I will present the solution with Azure Resources Manager (ARM) for automated deployment.


Before we begin here is what we need:

  • The source code of our azure function on the calculation of a PGCD;
  • Azure CLI installed;
  • The Func command that allows creation, local execution and many other actions on Azure functions;
  • A Terminal or Visal Code for the execution of CLI commands;
  • An Azure subscription to be able to carry out the publication and tests;
  • I use the CURL command to test calls to the function.

So, when we have all our “ingredients” we will be able to start the “recipe”. Let’s go!!

The sources

I voluntarily used Visual Code to retrieve the sources. To test and validate that my function compiles well, works properly and then be able to publish it on Azure.

To do this, simply review the demo ticket on azures functions. In short:

  • Start Visual Code;
  • Open your directory containing the sources;
  • Open a Terminal;
  • Execute the func command;
  • Perform a curl or browser command.

func start

If all goes well the command gives you the url to call to test your function, like this:

curl “http://localhost:666/api/pgcd?X=120&Y=8”

in response the following message must be provided:

Azure Function for calculated PGCD(120,8) is 8

So, we know that our function is ready to go online. But first, we need to prepare our resources on Azure.

Azure Environment

To deploy and execute our Azure function, we need multiple resources. In the interest of simplicity of understanding I stopped to provide the prerequisites in the orders and I did not go into more details. The aim is to publish a function and make it available.

Here is the list of resources:

Resource Group

All resources must belong to a group of resources. It is a functional container with a set of metadata. Moreover, they can only belong to one group of resources at a time.

We will therefore place the following order:

az group create --name functionapp-rg --location francecentral

to check the status of our group resource we can place the following command:

az group list --output table

who will return to us (for my part I had no group of resources before):

Name            Location       Status   
--------------  -------------  ---------
functionapp-rg  francecentral  Succeeded


az group show --name functionapp-rg -otable

Storage Account

Now we need a storage account. To make it simple a storage account will allow us to store all types of information in Azure in a single domain name and accessible via HTTP/S. The data is durable, secure and highly available.

For this we will place the following command to make its creation and assign it to our group resource created previously.

az storage account create --name funcaccount --resource-group functionapp-rg 

After a more or less long delay, an object in JSON format will appear.

The information on the storage account(s) can be obtained with the following command:

az storage account list -o table

To have the information on our account only the following order:

az storage account show --name funcaccount  

Function Application

Its purpose is to provide functions within it with an execution context and behavior defined by the Function App. It is important to remember that all functions in a Function App must have the same development language.

The scability is at the Function App level which means that scaling is done on all functions in the application. They therefore share all the resources per function instance.

The Deployment is done on all the functions of the application.

We will now create our Function App with the following command:

az functionapp create --name pgcdfuncapp --resource-group functionapp-rg --storage-account funcaccount --consumption-plan-location francecentral --functions-version 3

Description of parameters


This is the name of our new FunctionApp.


This is the name of the resource group where we want to implement our function application.


This is the storage account we created just before.


This is the geographical location where our function application will be hosted. If you want to have a list of available locations, simply place the following command:

az functionapp list-consumption-locations -o table

This is the runtime version for Azures Functions, currently there is version 1.x 2.x 3.x. By default, the version is 2.x, so here we will use version 3.x.

Publication of our Function

Now that we have created our infrastructure in Azure to host our function. We will deploy it. To do this, using our terminal session we will go to the directory that contains the project file of our function. Then we will use the following command:

func azure functionapp publish pgcdfuncapp

Testing our online function

If the deployment has been successfully completed. the command report will give you a semblance of the following message:

Deployment completed successfully.
Syncing triggers...
Functions in pgcdfuncapp:
    pgcddemo - [httpTrigger]
        Invoke url: https://pgcdfuncapp.azurewebsites.net/api/pgcd?code=goc4uOYiqbXR4mVi6XhFL3/Y8sPr0G1K9Sh0h62uZK3avVsVgZePEg==

To test I will use the following curl command:

curl "https://pgcdfuncapp.azurewebsites.net/api/pgcd?code=goc4uOYiqbXR4mVi6XhFL3/Y8sPr0G1K9Sh0h62uZK3avVsVgZePEg==&X=123&y=78"

The result will be:

Azure Function for calculated PGCD(123,78) is 3

Description des paramètres

X et Y

Sont les paramètres propres à la fonction de calcul du PGCD.


C'est le jeton de sécurité qui permet à l'appelant d'accéder et d'exécuter la fonction. D'autres moyen au niveau sécurité
sont disponibles car plus sécuritaire.

Destruction des ressources

Description of parameters

X and Y

Are the parameters specific to the DMP calculation function.


It is the security token that allows the caller to access and execute the function. 
Other means at the security level are available because they are safer.

Destruction of resources

As it was only for a demonstration we will clean up the resources allocated on our subscription to avoid any unnecessary expenses. To do this, just delete our group of resources and Azure will take charge of destroying taking into account any dependencies all the resources contained. Knowing that if a resource has a lock, it will not be destroyed. To do so, simply perform the following command:Comme ce n’était que pour une démonstration nous allons nettoyer les ressources allouées sur notre souscription pour éviter d’éventuelles dépenses inutiles. Pour cela, il suffit de supprimer notre groupe de ressources et Azure va se charger de détruire en tenant compte des éventuelles dépendances l’ensemble des ressources contenues. En sachant que si une ressource a un verrou elle ne sera pas détruite. Pour cela, il suffit juste d’effectuer la commande suivante :

az group delete --name functionapp-rg


Now you are able to:

  • develop an azure function ;
  • set up the minimum Azure infrastructure to accommodate your function ;
  • call up an application or a command to it ;
  • to destroy all resources.


Frédéric Schmidt

Frédéric Schmidt

Software Architect

I'm Software Developer & Architect. I'm more than 20 years experiences in differents IT service companies and software editors. I like studies some new technologies and share this passion altroughts my technical blog.


Technical writer

Social Media


Related Posts

Azure Function - Presentation
Microsoft Azure
Azure Function - Presentation
September 10, 2020
1 min
GO and Functions
Programming Languages
GO and Functions
May 21, 2020
1 min
© 2022, All Rights Reserved.

Quick Links

Contact Us

About me

Social Media