Skip to content

Instantly share code, notes, and snippets.

@doodlemania2
Created February 12, 2019 19:01
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 doodlemania2/80b0929714fa93a77e5df27b6dcd8bfb to your computer and use it in GitHub Desktop.
Save doodlemania2/80b0929714fa93a77e5df27b6dcd8bfb to your computer and use it in GitHub Desktop.
#LAMP-Final
#pre-reqs:
#AIRS subscription
#Azure BASH cloudshell
#YML for nonbyos (LINK)
#VS Code with Azure tooling installed preferrable but not required
#Setup runtime variables - replace each of this with your own. Make them substantially unique
rg=XXX
loc=eastus
appplan=XXX
app=XXX
mysql=XXX
mysqlpass=XXX\backescapechars\!
mysqladmin=XXX
mysqladminuser=$mysqladmin'@'$mysql
mysqldbname=wordpress
redis=XXX
###Optional if not using default AIRS: az account set -s 'XXX' #use your own subscription here of course
az group create --name $rg -l $loc
az mysql server create -g $rg --name $mysql -l $loc --admin-user $mysqladmin --admin-password $mysqlpass --sku-name B_Gen5_2 --version 5.7
az mysql server firewall-rule create --name allAzureIPs --server $mysql -g $rg --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0
az mysql db create -g $rg --server-name $mysql --name $mysqldbname
az redis create -g $rg -l $loc -n $redis --sku basic --vm-size C0 --enable-non-ssl-port
az redis list-keys --name $redis -g $rg #(copy primary key and run next command to set variable)
az redis list-keys --name $redis -g $rg | grep "primaryKey" | cut -d":" -f2 | cut -d "," -f1 | sed 's/ //g' | sed 's/"//g' | grep -v ^$
az appservice plan create --name $appplan -g $rg --sku s1 --is-linux
az webapp create -n $app -g $rg -p $appplan --multicontainer-config-file docker-compose-wordpress-nonbyos.yml --multicontainer-config-type compose
az webapp log config --application-logging true -g $rg -n $app --web-server-logging filesystem
az webapp config appsettings set -g $rg -n $app --settings WORDPRESS_DB_HOST=$mysql'.mysql.database.azure.com' WORDPRESS_DB_USER=$mysqladminuser WORDPRESS_DB_PASSWORD=$mysqlpass WORDPRESS_DB_NAME=$mysqldbname MYSQL_SSL_CA="BaltimoreCyberTrustroot.crt.pem" WP_REDIS_HOST=$redis'.redis.cache.windows.net' WP_REDIS_PASSWORD=$rediskey WEBSITES_ENABLE_APP_SERVICE_STORAGE=TRUE
az webapp log tail -g $rg -n $app #watch for slow startup due to building out app, a few 502s isn't bad, may also have to kick it with a restart
#hit the site - patience
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment