This how-to guide shows you how to deploy your app to Azure App Service from a Git repository on your local computer.
Note
This deployment method requires SCM basic authentication, which is less secure than other deployment methods. When Local Git deployment doesn't work, you can't configure Local Git deployment in the app's Deployment Center.
To get automated builds from Azure App Service build server, make sure that your repository root has the correct files in your project.
Runtime
Root directory files
ASP.NET (Windows only)
*.sln, *.csproj, or default.aspx
ASP.NET Core
*.sln or *.csproj
PHP
index.php
Ruby (Linux only)
Gemfile
Node.js
server.js, app.js, or package.json with a start script
Python
*.py, requirements.txt, or runtime.txt
HTML
default.htm, default.html, default.asp, index.htm, index.html, or iisstart.htm
WebJobs
<job_name>/run.<extension> under App_Data/jobs/continuous for continuous WebJobs, or App_Data/jobs/triggered for triggered WebJobs. For more information, see Kudu WebJobs documentation.
Run az webapp create with the --deployment-local-git option. For example:
Azure CLI
az webapp create --resource-group<group-name>--plan<plan-name>--name<app-name>--runtime"<runtime-flag>"--deployment-local-git
The output contains a URL like: https://<deployment-username>@<app-name>.scm.azurewebsites.net/<app-name>.git. Use this URL to deploy your app in the next step.
Run New-AzWebApp from the root of your Git repository. For example:
Azure PowerShell
New-AzWebApp -Name <app-name>
When your run this cmdlet from a directory that's a Git repository, it automatically creates a Git remote to your App Service app for you, named azure.
In the portal, you need to create an app first, then configure deployment for it. See Configure an existing app.
az webapp deployment source config-local-git --name<app-name>--resource-group<group-name>
The output contains a URL like: https://<deployment-username>@<app-name>.scm.azurewebsites.net/<app-name>.git. Use this URL to deploy your app in the next step.
In the Azure portal, navigate to your app's management page.
From the left menu, select Deployment Center > Settings. Select Local Git in Source, then select Save.
In the Local Git section, copy the Git Clone Uri for later. This Uri doesn't contain any credentials.
Deploy the web app
In a local terminal window, change the directory to the root of your Git repository, and add a Git remote using the URL you got from your app. If your chosen method doesn't give you a URL, use https://<app-name>.scm.azurewebsites.net/<app-name>.git with your app name in <app-name>.
If your Git remote URL already contains the username and password, you won't be prompted.
Review the output. You might see runtime-specific automation, such as MSBuild for ASP.NET, npm install for Node.js, and pip install for Python.
Browse to your app in the Azure portal to verify that the content is deployed.
Change deployment branch
When you push commits to your App Service repository, App Service deploys the files in the master branch by default. Because many Git repositories are moving away from master to main, you need to make sure that you push to the right branch in the App Service repository in one of two ways:
Deploy to master explicitly with a command like:
Bash
git push azure main:master
Change the deployment branch by setting the DEPLOYMENT_BRANCH app setting, then push commits to the custom branch. To do it with Azure CLI:
Azure CLI
az webapp config appsettings set --name<app-name>--resource-group<group-name>--settings DEPLOYMENT_BRANCH='main'
git push azure main
You can also change the DEPLOYMENT_BRANCH app setting in the Azure portal, by selecting Environment variables under Settings and adding a new App setting with a name of DEPLOYMENT_BRANCH and value of main.
Troubleshoot deployment
You might see the following common error messages when you use Git to publish to an App Service app in Azure:
Message
Cause
Resolution
Unable to access '[siteURL]': Failed to connect to [scmAddress]
The app isn't up and running.
Start the app in the Azure portal. Git deployment isn't available when the web app is stopped.
Couldn't resolve host 'hostname'
The address information for the azure remote is incorrect.
Use the git remote -v command to list all remotes, along with the associated URL. Verify that the URL for the azure remote is correct. If needed, remove and recreate this remote using the correct URL.
No refs in common and none specified; doing nothing. Perhaps you should specify a branch such as 'main'.
You didn't specify a branch during git push, or you haven't set the push.default value in .gitconfig.
Run git push again, specifying the main branch: git push azure main.
Error - Changes committed to remote repository but deployment to website failed.
You pushed a local branch that doesn't match the app deployment branch on azure.
Verify that current branch is master. To change the default branch, use DEPLOYMENT_BRANCH application setting (see Change deployment branch).
src refspec [branchname] does not match any.
You tried to push to a branch other than main on the azure remote.
Run git push again, specifying the main branch: git push azure main.
RPC failed; result=22, HTTP code = 5xx.
This error can happen if you try to push a large git repository over HTTPS.
Change the git configuration on the local machine to make the postBuffer bigger. For example: git config --global http.postBuffer 524288000.
Error - Changes committed to remote repository but your web app not updated.
You deployed a Node.js app with a package.json file that specifies additional required modules.
Review the npm ERR! error messages before this error for more context on the failure. The following are the known causes of this error, and the corresponding npm ERR! messages:
Native module doesn't have a binary distribution for Windows: npm ERR! \cmd "/c" "node-gyp rebuild"\ failed with 1 or npm ERR! [modulename@version] preinstall: \make \|\| gmake\
შემოუერთდით Meetup სერიას, რათა შექმნათ მასშტაბური AI გადაწყვეტილებები რეალურ სამყაროში გამოყენების შემთხვევებზე დაყრდნობით თანამემამულე დეველოპერებთან და ექსპერტებთან.
In this learning path, get acquainted with using Azure App Service to create and deploy your website without underlying servers, storage or network assets.
Build end-to-end solutions in Microsoft Azure to create Azure Functions, implement and manage web apps, develop solutions utilizing Azure storage, and more.