Skip to content

Instantly share code, notes, and snippets.

@sjwaight
Last active June 30, 2017 03:53
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 sjwaight/d65a04036cd6ceda63bf90485e22adb4 to your computer and use it in GitHub Desktop.
Save sjwaight/d65a04036cd6ceda63bf90485e22adb4 to your computer and use it in GitHub Desktop.
bash script that can be used to setup a new App Service Plan and Web App instance
#!/bin/sh
azuresub=$1
demolocation=$2
demoresourcegroup=$3
mysqlservername=$4
mysqladminuser=$5
mysqladminpass=$6
appplanname=$7
webappname=$8
# uncomment to add local support and login to your Azure subscription
# az login
az account set --subscription $azuresub
# idempotent so you can call as many times as you like if it already exists.
az group create --location $demolocation --name $demoresourcegroup
az appservice plan create --name $appplanname --resource-group $demoresourcegroup --location $demolocation --sku B1
az webapp create --name $webappname --resource-group $demoresourcegroup --plan $appplanname
echo "Make sure you note the "outboundIpAddresses" in the response to the previous command."
# Setup a connection string for the Web App to access our previously created MySQL instance (running in same resource group)
az webapp config connection-string set --resource-group $demoresourcegroup --name $webappname -t mysql --settings defaultconnection="Data Source=${mysqlservername}.mysql.database.azure.com; User Id=${mysqladminuser}@${mysqlservername}; Password=${mysqladminpass}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment