cloudymax / CloudyDevDotNet

My personal webpage

Home Page:https://www.cloudydev.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Static website hosting for ~$0.05 /month

How I host my personal site in an Azure Storage Blob.

1. Install the Azure CLI

curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

2. Log In

az login

3. List Subscriptions

❯ az account list -o table                     
Name           CloudName    SubscriptionId                            State    IsDefault
-------------  -----------  ------------------------------------      -------  -----------
cloudydev.net  AzureCloud   d520e0d1-8ce2-4bf3-bb06-443ee372cfec      Enabled  True
    ```

4. Export variables and keep things DRY

export KIND="StorageV2"
export LOCATION="westeurope"
export SUBSCRIPTION="cloudydev.net"
export RG_NAME="cloudydev-docs"
export STORAGE_NAME="cloudydevdata"
export STORAGE_SKU="Standard_RAGRS"
export ERROR_DOC="index.html"
export INDEX_DOC="index.html"
export SITE_ROOT_FOLDER="site"

5. Set subscription

az account set --subscription="${SUBSCRIPTION}"

6. Create a resource group

az group create \
  -l="${LOCATION}" \
  -n="${RG_NAME}"

7. Create storage account

  az storage account create \
    --name="${STORAGE_NAME}" \
    --resource-group="${RG_NAME}" \
    --location="${LOCATION}" \
    --sku="${STORAGE_SKU}" \
    --kind="${KIND}"

8. Enable static website hosting

  az storage blob service-properties update \
    --account-name="${STORAGE_NAME}" \
    --static-website \
    --404-document="${ERROR_DOC}" \
    --index-document="${INDEX_DOC}" \
    --auth-mode login

9. Upload Files

 az storage blob upload-batch \
     -s "${SITE_ROOT_FOLDER}" \
     -d '$web' \
     --account-name="${STORAGE_NAME}"

10. Get the URL

az storage account show \
  -n "${STORAGE_NAME}" \
  -g "${RG_NAME}" \
  --query "primaryEndpoints.web" \
  --output tsv
# https://cloudydevdata.z6.web.core.windows.net/  

About

My personal webpage

https://www.cloudydev.net/