Posted in:

Azure App Service allows you to configure an external Git repository from which it can pull down code from. This works for both Web Sites and Function Apps, and can be configured as part of your ARM template.

But once you’ve configured the location of the external repository, simply pushing new commits to that external git repository won’t cause your website/function app to automatically update.

Instead you need to go into the Deployments section of the portal and click the Sync button:

image

When you click sync, it pulls down any new commits from the external git repository, and deploys them for you.

But how can we automate this process? We don’t want to have to manually go into the portal as part of our deployment. Here’s two ways I found…

Method 1 – PowerShell

The first technique uses Azure PowerShell. I’ll assume you’re already logged in and have the correct subscription selected. You can use these commands to do that if you’re new to Azure PowerShell.

Login-AzureRmAccount
Select-AzureRmSubscription –SubscriptionName "My Sub"

Now, so long as we know the name of our WebSite/Function app and the resource group it is in, we can request a sync with the following command (thanks to David Ebbo):

Invoke-AzureRmResourceAction -ResourceGroupName "MyResourceGroup" -ResourceType Microsoft.Web/sites -ResourceName "MyFuncApp" -Action sync -ApiVersion 2015-08-01 -Force –Verbose

Method 2 – Azure CLI

I’ve only just started using the Azure CLI, but I like what I’ve seen so far. Its nice and simple to work with and you can easily explore the available commands just by typing az.

Just like with PowerShell we do need to make sure we’re logged in and have the correct subscription selected, which we can do with:

az login
az account set –s "My Sub"

And now to request a sync, we can call the sync action for our deployment source. Here’s the syntax for a function app

az functionapp deployment source sync –g MyResGroup –n MyFunctionApp

If it was a webapp instead, it’s pretty much the same:

az webapp deployment source sync –g MyResGroup –n MyWebApp

Method 3 – App Service Continuous Deployment Alternatives

There are several other ways to tackle this problem, by integrating with VSTS, setting up web hooks, or using local git repositories but the techniques described above will be useful if you picked the external git repository option.

Want to learn more about how easy it is to get up and running with Azure Functions? Be sure to check out my Pluralsight courses Azure Functions Fundamentals and Microsoft Azure Developer: Create Serverless Functions

Comments

Comment by Ivan Bilimov

So, why the --manual-integration key does exist?

Ivan Bilimov