Skip to content

Instantly share code, notes, and snippets.

@robconery
Last active November 23, 2023 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robconery/ecb7cc0cfd765f659f5b86e44e0bb9e2 to your computer and use it in GitHub Desktop.
Save robconery/ecb7cc0cfd765f659f5b86e44e0bb9e2 to your computer and use it in GitHub Desktop.
az webapp creation
#!/bin/bash
USER=deployer
PASS=[pick something]
APPNAME=[your app name]
RG=[your resource group]
SP=[your service plan]
#you can see a list of runtimes using
#az webapp list-runtimes --linux
RUNTIME=[pick your runtime from the list above]
# Create a resource group if you need it.
az group create --location westus --name $RG
# Create an App Service plan in FREE tier if you need it.
az appservice plan create --name $APPNAME --resource-group $RG --sku FREE
echo "Creating web app..."
# Create a web app. I'm using the Node runtime here but
az webapp create --name $APPNAME --resource-group $RG --plan $SP --runtime "$RUNTIME"
echo "Setting credentials"
# Set the account-level deployment credentials
az webapp deployment user set --user-name $USER --password $PASS
echo "Setting DEPLOY URL"
# Configure local Git and get deployment URL
DEPLOY_URL=https://$USER:$PASS@$APPNAME.scm.azurewebsites.net/$APPNAME.git
echo "Deploying"
# Add the Azure remote to your local Git respository and push your code
git remote rm azure #just in case
git remote add azure $DEPLOY_URL
git push azure master
# When prompted for password, use the value of $password that you specified
# Copy the result of the following command into a browser to see the web app.
echo https://$APPNAME.azurewebsites.net
#to clean this up you can drop the resource group with
#az group delete $RG
#or just delete the webapp
#az webapp delete $APPNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment