Last active
March 22, 2022 14:38
-
-
Save ozkary/d99a4ef4907d5834203df1bd183dc0da to your computer and use it in GitHub Desktop.
CLI Script to create Azure Static Wep App Resource
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # Purpose: Use the bash file to automate the creation of an Azure Static Web App with CICD Github Pipeline | |
| # Requirements: Azure subscription, Github branch and repo token | |
| # Author: 0garcia - ozkary | |
| # Article: https://www.ozkary.com/2021/02/azure-static-web-app-github-actions-cicd.html | |
| # | |
| clear | |
| # creates the azure resources for a static web app with github cicd pipeline | |
| echo "creates the azure resources for a static web app with github cicd pipeline" | |
| echo "*************************************************************************" | |
| # prompt for the username and pasword | |
| read -p "username: " username | |
| echo | |
| read -sp "password: " password | |
| echo | |
| echo "login to azure" | |
| az login -u $username -p $password | |
| # display the current account | |
| echo "******" | |
| echo "showing current account" | |
| az account show | |
| echo "# set the default subscription" | |
| echo "******" | |
| read -p "subscription name: " subscription | |
| echo "setting current subscription" $subscription | |
| az account set -s $subscription | |
| echo "# create a resource group to hold the resources" | |
| echo "******" | |
| read -p "resource group name: " group | |
| read -p "resource group location (EastUS,WestUS): " location | |
| read -p "resource group tag (dev/stg/prd): " tag | |
| echo "creating resource group " $group $location $tag | |
| az group create -n $group -l $location --tags $tag | |
| echo "# deploy the web app with github deployment support" | |
| echo "******" | |
| echo "enter information for the app with github information. Ready the token and branch name" | |
| read -p "app name: " app | |
| read -p "Github repo url: " repo | |
| read -p "Github branch name: " branch | |
| read -p "Github token: " token | |
| read -p "app hosting (Free/Standard): " sku | |
| read -p "app tag (dev/stg/prd): " apptag | |
| echo "creating app " $app $repo $branch $token $sku $apptag | |
| az staticwebapp create -n $app -g $group -s $repo -l $location -b $branch --token $token --sku $sku --tags $apptag | |
| echo "# set the static app settings" | |
| echo "******" | |
| echo "enter app configuration with the key=value format with space as delimeter" | |
| echo "example: apiurl=https://ozkary.com/api apikey=123448484 [email protected]" | |
| read -p "configuration information " config | |
| echo "adding app configuration" $config | |
| az staticwebapp appsettings set -n $app --setting-names $config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment