Using Deployment slots for Azure Function

Using Deployment slots for Azure Function

Deployment slots are extremely useful components for Azure cloud services. Deployment slots enable isolation of application environments such as development, staging, and production in a seamless manner. We can swap the environment very easily and thus enable rapid deployment, easy roll out or rollback of the solution and overall enabling DevOps for cloud solution development.

If you are using Azure App Services, you must be familiar with the deployment slots. Now, Azure Functions also support the deployment slots feature (which is currently in preview)

Azure Function Getting Started :

Creating Deployment slots for Azure Function:

To create a deployment slot for your Azure Functions, navigate to the resources in the Azure Portal and then select the “+” icon with “Slots(preview)” option.

Select Slots option for Azure Functions

In the “Create a new deployment slot” screen, provide the name of your deployment slot and click on “Create”. In this case we choose the name as “staging”

Create Deployment Slot


It will take a while to create the slot. Once the slot is created, you will find a slot named “Staging” under the “Slots” options and with that, you have two different environments for your Azure Function – productions (the previous version of Azure Functions)  and staging.

Different Deployment Slots for Azure Functions

Deploying to Deployment slots for Azure Function

Instead of further exploring anything here, let’s go back to Visual Studio and change some code to our existing code base (refer to this post or change some of your existing code bases) – and just renamed the function name from “Function1” to “MyNewFunction”.  Right click on the solution and select “Publish” option. Choose “New Profile” option and click on Publish. From “Pick a publish target”, choose “Azure Function App” and instead of new, “Select Existing

Select Deployment Options


This will bring your existing App Service selection screen and you will find the newly created deployment slot here.

Deploy from Visual Studio in Staging


Select the option “Staging” and then click on OK

With that, Visual Studio will start a new deployment to the deployment slots. So, what we have done here, though there is a change in our code, we are not deploying the updated version to production, rather putting it in a different slot for further verification. This will help us verify the changes first before we move to production.

Once the deployment is completed, go back to Azure Portal and notice that the Staging version of your Azure Functions has an updated function, “MyNewFunction” ( with all code changes if you have any ..)

Noticed that, the MyFunctionAppVS – which considered to be as your production version of the Azure function remains unchanged and the version of the function remains same “Function1” whereas the staging slot has the different version of the code with new function MyNewFunction.

New Version of Deployment of Azure Function

Testing Azure Function Deployment Slots :

Test out the staging version of Azure Function by redirecting to staging URL https://yourfunctonap-<deploymentslotname>, and you can execute your new function. Where is if you refer to old URL of a production version of the function, you are still calling the existing function.

Different Version of Slots URL Test


Hope, now this is very clear to you on how we are using two different version of environments to keep two version of application alive and continue testing your newly developed code before we push it to production. Once all the test passes and you are sure to go ahead with new code base to production you just need swap the slots by selecting the “Swap” link.

Swap Slots

This will bring the swap bladed for swapping the deployment source. Choose the source as production, and destination as Staging and then click on ok.

Swap Deployment Slots

Once the swap is completed you can verify the functions are changed between the slots, which mean you have the latest version of code updated in production.

Changes in Slots

At any point in time, if you want to rollback, you can just swap the slots again. Explore the preview version of the Azure Function deployment slots and check how it can help in your cloud solution. In next post, we will talk about more on automated deployments.

Hope this helps.

Geek’s Choice
Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.