Create an App Service app with deployment from GitHub using Azure CLI
This sample script creates an app in App Service with its related resources. It then deploys your app code from a public GitHub repository (without continuous deployment). For GitHub deployment with continuous deployment, see Create an app with continuous deployment from GitHub.
Use Azure Cloud Shell using the Bash environment.
If you prefer, install the Azure CLI to run CLI reference commands.
- If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For additional sign-in options, see Sign in with the Azure CLI.
- When you're prompted, install Azure CLI extensions on first use. For more information about extensions, see Use extensions with the Azure CLI.
- Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade.
- This tutorial requires version 2.0 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
#!/bin/bash # Replace the following URL with a public GitHub repo URL gitrepo=https://github.com/Azure-Samples/php-docs-hello-world webappname=mywebapp$RANDOM # Create a resource group. az group create --location westeurope --name myResourceGroup # Create an App Service plan in `FREE` tier. az appservice plan create --name $webappname --resource-group myResourceGroup --sku FREE # Create a web app. az webapp create --name $webappname --resource-group myResourceGroup --plan $webappname # Deploy code from a public GitHub repository. az webapp deployment source config --name $webappname --resource-group myResourceGroup \ --repo-url $gitrepo --branch master --manual-integration # Copy the result of the following command into a browser to see the web app. echo http://$webappname.azurewebsites.net
Clean up deployment
After the sample script has been run, the following command can be used to remove the resource group and all resources associated with it.
az group delete --name myResourceGroup
This script uses the following commands. Each command in the table links to command specific documentation.
||Creates a resource group in which all resources are stored.|
||Creates an App Service plan.|
||Creates an App Service app.|
||Associates an App Service app with a Git or Mercurial repository.|
For more information on the Azure CLI, see Azure CLI documentation.
Additional App Service CLI script samples can be found in the Azure App Service documentation.