Exercise - View replication status

Completed

In this unit, you'll create a storage account and configure a blob container for it. You'll create a blob file and upload it to your storage account. You can then view the replication status in the Azure portal.

Important

You need your own Azure subscription to run this exercise, and you might incur charges. If you don't already have an Azure subscription, create a free account before you begin.

Create a storage account

Create a storage account with geo-zone-redundant storage (GZRS).

  1. Sign in to the Azure portal.

  2. From the menu bar in the upper right, open Cloud Shell. Select the Bash option.

  3. Set the resource group name by running the following command.

    export RESOURCEGROUP=learn-storage-replication-rg
    
  4. To set the storage account, run the following command. Replace storageaccountname and the brackets with a unique Azure Storage account name.

    Note

    Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.

    export AZURE_STORAGE_ACCOUNT=<storageaccountname>
    
  5. Set the location. Replace the westus2 value with a location near you.

    export LOCATION=westus2
    

    The following list has some location values you can use:

    • southeastasia
    • northeurope
    • westeurope
    • japaneast
    • uksouth
    • centralus
    • eastus2
    • westus2
  6. To create a resource group, run this command:

    az group create --name $RESOURCEGROUP --location $LOCATION
    
  7. To create a storage account, run this command:

    az storage account create \
    --name $AZURE_STORAGE_ACCOUNT \
    --resource-group $RESOURCEGROUP \
    --location $LOCATION \
    --sku Standard_GZRS \
    --encryption-services blob \
    --kind StorageV2
    
  8. For the rest of the steps in this exercise, you'll need your storage credentials. To list your storage account keys, run this command:

    az storage account keys list \
    --account-name $AZURE_STORAGE_ACCOUNT \
    --resource-group $RESOURCEGROUP \
    --output table
    
  9. Copy the keys listed.

  10. To hold your storage key, set an environment variable. Replace account-key and the brackets with one of your key values.

    export AZURE_STORAGE_KEY="<account-key>"
    

Create a blob container

To upload blobs to Azure Storage, you need a container. You can use containers to logically group your blobs. A container helps you organize blobs, like a folder organizes files on your computer.

  1. Use the following command to set a container name. Replace blob-container-name and the brackets with a unique name.

    export BLOB_CONTAINER_NAME=<blob-container-name>
    
  2. Run the following command to create a container for your storage account:

    az storage container create --account-key $AZURE_STORAGE_KEY --account-name $AZURE_STORAGE_ACCOUNT --name $BLOB_CONTAINER_NAME
    
  3. When your storage account container has been created, you'll see this message returned in your terminal:

    {
        "created": true
    }
    

Create a file (blob)

Your company uploads its music files as blobs in the container. A blob can represent a file of any type. For the purposes of this exercise, you'll upload a text file as a blob.

  1. To create a file you can upload to your storage account, run this command:

    cat > song.mp3
    
  2. This creates an empty file to which you can write. Enter This is a song!, select Enter, and then select Ctrl+D.

  3. To see the contents of your song.mp3 file, run this command:

    cat song.mp3
    
  4. You'll see This is a song! returned to you in the terminal. You've created a file you can now upload to your storage account.

Upload your file

Upload the file to your storage account via your container.

  1. To upload your file, run this command:

    az storage blob upload \
        --container-name $BLOB_CONTAINER_NAME \
        --name song \
        --file song.mp3
    
  2. When the upload is complete, verify the file is in your storage account by running this command:

    az storage blob list \
    --container-name $BLOB_CONTAINER_NAME  \
    --output table
    
  3. You'll see details about your file, like its name, blob type, and when it was last modified.

View the replication status

  1. Sign in to the Azure portal.

  2. On the home page, select or search for Resource groups.

  3. Select learn-storage-replication-rg. The learn-storage-replication-rg resource group pane appears.

  4. Select the storage account you created from the list of resources in your resource group. Your storage account pane appears.

  5. In the left menu pane, under Data management, select Redundancy. The Redundancy pane appears for your storage account. You'll find the replication status of your Azure storage account's primary and secondary regions. If the status shows as Available for a region, it means your region is responsive.

  6. To ensure you're seeing the latest status updates, select Refresh in the top menu bar.

    Screenshot of the geo-replication map that shows the primary and secondary locations available.

It'll take some time for your data to replicate from the primary to the secondary region.