Create a web app and deploy code from a local Git repository
This sample script creates a web app in App Service with its related resources, and then deploys your web app code from a local Git repository.
If needed, update to the latest Azure PowerShell using the instruction found in the Azure PowerShell guide, and then run
Connect-AzAccount to create a connection with Azure. Also, your application code needs to be committed into a local Git repository.
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure PowerShell.
$gitdirectory="<Replace with path to local Git repo>" $webappname="mywebapp$(Get-Random)" cd $gitdirectory # Create a web app and set up Git deployement. New-AzWebApp -Name $webappname # Push your code to the new Azure remote git push azure master
Clean up deployment
After the script sample has been run, the following command can be used to remove the resource group, web app, and all related resources.
Remove-AzResourceGroup -Name $webappname -Force
This script uses the following commands. Each command in the table links to command specific documentation.
|New-AzWebApp||Creates a web app with necessary resource group and App Service group. When the current directory contains a Git repository, also add an
For more information on the Azure PowerShell module, see Azure PowerShell documentation.
Additional Azure Powershell samples for Azure App Service Web Apps can be found in the Azure PowerShell samples.
Send feedback about: