Skip to content

Instantly share code, notes, and snippets.

@kimsk
Created March 11, 2019 21:12
Show Gist options
  • Save kimsk/67e339aa9c4d9ae7ada3a435e6275913 to your computer and use it in GitHub Desktop.
Save kimsk/67e339aa9c4d9ae7ada3a435e6275913 to your computer and use it in GitHub Desktop.
Manage Static Website on Azure Storage using Azure CLI

Instructions (using PowerShell)

Initial

$resourceGroup = "myResource"
$storageName = "myStorage"
$location = "southcentralus"
$sku = "Standard_RAGRS"
$kind = "StorageV2"

Setup Storage Account

# create storage account
az storage account create `
    --name $storageName `
    --resource-group $resourceGroup `
    --location $location `
    --sku $sku `
    --kind $kind

# enable static website feature
az storage blob service-properties update --account-name $storageName --static-website --404-document 404.html --index-document index.html

Others

Upload files

# upload files to $web
az storage blob upload-batch -s "./build" -d '$web' --account-name $storageName

List

# show endpoint url
az storage account show -n $storageName -g $resourceGroup --query "primaryEndpoints.web" --output tsv


# list storage name by resource group name
az storage account list --query "[?resourceGroup=='$resourceGroup'].name"

az storage account list --query "[?name=='$storageName']"

CDN

Delete

# delete storage account
az storage account delete -g $resourceGroup -n $storageName -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment