Created
March 4, 2016 00:06
-
-
Save jim80net/591802d87e3c744f7814 to your computer and use it in GitHub Desktop.
Create premium storage account in azure for use in BOSH deployment
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 | |
| function USAGE() { | |
| echo "Usage: make_fast_storage.sh <storage_account_name>" | |
| echo "Note: Should be logged into the Azure CLI before running" | |
| echo "STDIN: none expected" | |
| echo "STDOUT: Azure CLI output" | |
| echo "STDERR: Azure CLI errput" | |
| } | |
| AZURE_REGION="southcentralus" | |
| RESOURCE_GROUP_NAME="TODO_WHATISMYRESOURCEGROUPNAME" | |
| STORAGE_ACCOUNT_NAME=$1 | |
| [[ "$STORAGE_ACCOUNT_NAME" == "" ]] && { USAGE; exit 1; } | |
| azure storage account create --location "$AZURE_REGION" --type PLRS --resource-group "$RESOURCE_GROUP_NAME" "$STORAGE_ACCOUNT_NAME" && { | |
| echo "Successfully created account $STORAGE_ACCOUNT_NAME" | |
| } || { | |
| echo "Could not create account $STORAGE_ACCOUNT_NAME" | |
| exit 1 | |
| } | |
| STORAGE_ACCOUNT_KEY=`azure storage account keys list --json --resource-group "$RESOURCE_GROUP_NAME" "$STORAGE_ACCOUNT_NAME" | jq --raw-output '.key1'` | |
| [[ "$STORAGE_ACCOUNT_KEY" == "null" ]] && { echo "error parsing storage account key"; exit 1; } | |
| function CREATE_STORAGE_CONTAINER() { | |
| CMD="azure storage container create --account-name "$STORAGE_ACCOUNT_NAME" --account-key "$STORAGE_ACCOUNT_KEY" $1" | |
| echo $CMD | |
| $CMD && { | |
| echo "Created $1 container" | |
| } || { | |
| echo "Could not create $1 container" | |
| exit 1 | |
| } | |
| } | |
| CREATE_STORAGE_CONTAINER bosh | |
| CREATE_STORAGE_CONTAINER stemcell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment