Module 2: Assignment - 1
Tasks To Be Performed:
- Create 2 resource groups rg-1 and rg-2
- Add storage account to rg-1
- Move storage account from rg-1 to rg-2
In the Azure Portal I navigate to the “Cloud Shell” Icon in the upper right corner
Step 1: Create Two Resource Groups
In the command-line interface and run:
az group create --name rg-1 --location eastus
az group create --name rg-2 --location eastus
Verify:
az group list -o table
Step 2: Add a Storage Account to rg-1
I create a new storage account in resource group rg-1
az storage account create --name hectorstorage12345 --resource-group rg-1 --location eastus --sku Standard_LRS
Verity:
az storage account list --resource-group rg-1 --query "[].{Name:name, ResourceGroup:resourceGroup}" -o table
Step 3: Move Storage Account from rg-1
to rg-2
First, I get the resource ID of the storage account by running:
az storage account show --name hectorstorage12345 --resource-group rg-1 --query id --output tsv
The ID is pretty long so I’ll store in a variable:
storageid=$(az storage account show --name hectorstorage12345 --resource-group rg-1 --query id --output tsv)
Using variable, I move the storage account to rg-2
with the following.
az resource move --destination-group rg-2 --ids $storageid
Verity:
The following command confirms storage account no longer in rg-1
az storage account list --resource-group rg-1 --query "[].{Name:name, ResourceGroup:resourceGroup}" -o table
The following confirms it is located in rg-2
az storage account list --resource-group rg-2 --query "[].{Name:name, ResourceGroup:resourceGroup}" -o table