Last active
May 27, 2022 10:01
-
-
Save ndamulelonemakh/b44f6179e8f00e5b7e3ed9c39e4f43b0 to your computer and use it in GitHub Desktop.
Azure deployment scripts for dev and small-scale production workloads
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 | |
| # Helper script to deploy the production optimised build of a react app to Azure | |
| # The environment variables below can be changed as required | |
| ResourceGroupName="my-example-rg" | |
| Location="westus" | |
| StorageAccountName="myspecialstorageaccount" | |
| StorageSKU="Standard_LRS" | |
| StorageKind="StorageV2" # Allowed values: BlobStorage, BlockBlobStorage, FileStorage, Storage, StorageV2 | |
| StorageContainerName="mysitecontainer01" | |
| StorageContainerPublicAccessScope="container" # Allowed values: blob, container, off | |
| StorageAccessTier="Hot" | |
| SiteName="chow" | |
| AppName="React App" | |
| BuildDir="public" | |
| GitHubRepoUrl="https://github.com/you-github-name/repo-name" | |
| # (Optional) Set the default location for all resources | |
| az login # If you have not done so already | |
| az config set default.location=$Location | |
| # Create a resource group to host your resources | |
| az group create -g $ResourceGroupName | |
| # Create a storage account | |
| az storage account create\ | |
| -n $StorageAccountName \ | |
| -g $ResourceGroupName \ | |
| --sku $StorageSKU \ | |
| --kind $StorageKind \ | |
| --access-tier $StorageAccessTier \ | |
| -verbose -o yamlc | |
| # Create a blob container to host the static site content - allow public access to all blobs within the container | |
| # NB: You need to obtain a SAS token to get authorization to modify the storage account | |
| az storage container create -n $StorageContainerName \ | |
| --sas-token $SAS_TOKEN \ | |
| --account-name $StorageAccountName \ | |
| --public-access $StorageContainerPublicAccessScope | |
| # Deploy static web app to Azure from Github | |
| az staticwebapp create \ | |
| -n $SiteName \ | |
| -g $ResourceGroupName \ | |
| --location $Location \ | |
| --source $GitHubRepoUrl \ | |
| --branch main \ | |
| --app-artifact-location $BuildDir \ | |
| --token $GITHUB_ACCESS_TOKEN \ | |
| --verbose -o yamlc | |
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
| # Reference: | |
| templateFile="{path-to-the-template-file}" | |
| devParameterFile="{path-to-azuredeploy.parameters.dev.json}" | |
| az group create \ | |
| --name myResourceGroupDev \ | |
| --location "East US" | |
| az deployment group create \ | |
| --name devenvironment \ | |
| --resource-group myResourceGroupDev \ | |
| --template-file $templateFile \ | |
| --parameters $devParameterFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment