Estimate before you build, then tag what you build so the bill can be split
Task
Use the Azure pricing calculator, without signing in, to see three of lesson 12's cost factors move an estimate: region, redundancy and access tier. Then create one small, private storage account in a tagged resource group and prove two rules from the lesson for yourself: a tag on a resource group does not flow down to the resources inside it, and a tag added to the resource itself is what lets you find it, and later report its cost, by meaning rather than by location. Finally, look at the same subscription in Microsoft Cost Management, where actual spending is grouped by that tag, and tell the forward-looking tool from the backward-looking one.
Steps
- Open Cloud Shell (Bash) and make sure you are working in the right subscription:
az account set --subscription 00000000-0000-0000-0000-000000000000
az account show --query name -o tsv
The second command prints your subscription's name. Nothing has been created yet. 2. Build an estimate before anything exists. In a new browser tab, search for Azure pricing calculator and open it; do not sign in, because lesson 12's point is that it works without a subscription. On the Products tab, choose Storage Accounts so it appears in your estimate. Set Region to East US, Redundancy to LRS, Access tier to Hot and a small capacity, and note the estimated monthly cost. Now change one setting at a time and watch the figure: set Redundancy to GRS, then set the access tier to Cool or Archive, then put the access tier back to Hot and pick a region on another continent. Write down which settings moved the figure. Changing the estimate's name moves nothing. You may use Export to download the estimate as a spreadsheet, but do not save or share it: it is a practice estimate and no Azure resource. 3. Create the lab's resource group, tagged with a cost centre and an environment, in the region you will use throughout:
az group create --name az900-lab12-rg --location eastus --tags CostCenter=CC-1001 Environment=Lab
Tags cost nothing and change nothing about how a resource runs. Never put a secret or personal data in a tag: anyone with read access, and every cost report, can see it. 4. Create one small, private storage account in that group. Storage account names are global, so replace the digits 48213 with four to six digits of your own, and use that same name everywhere below:
az storage account create --name az900lab1248213 --resource-group az900-lab12-rg --location eastus --sku Standard_LRS --kind StorageV2 --allow-blob-public-access false --min-tls-version TLS1_2
Standard_LRS is the cheapest redundancy option, which is one of the factors you just watched in the calculator. The account holds no data, so its charges stay minimal while it exists. 5. Check whether the group's tag reached the account:
az storage account show --name az900lab1248213 --resource-group az900-lab12-rg --query tags.CostCenter -o tsv
It prints an empty line. Tags are not inherited by default: the account sits inside a group tagged CC-1001 and carries no CostCenter tag of its own. Lesson 13's Azure Policy is the tool that can require or copy tags; here you add the tag yourself, merging it with any tags already there:
SA_ID=$(az storage account show --name az900lab1248213 --resource-group az900-lab12-rg --query id -o tsv)
az tag update --resource-id "$SA_ID" --operation Merge --tags CostCenter=CC-1001 Environment=Lab
- Find resources by meaning rather than by location. This lists every resource in the subscription that carries the cost centre tag, whichever resource group it is in:
az resource list --tag CostCenter=CC-1001 --query '[].name' -o tsv
It prints the name of your storage account. A project whose resources are scattered across several groups is reported the same way, which is why tags, not moving resources around, are the simple answer to "what does this project cost?". 7. Look at actual spending in the portal. Open Cost Management, choose Cost analysis, and make sure the scope is your subscription. Set Group by to Tag and pick CostCenter. Your new account will not appear yet: cost data usually arrives within a day, and an empty account costs next to nothing. Then open Budgets and read lesson 1's budget and its alert conditions, without changing them. Note the difference: the calculator estimated a resource that did not exist; Cost Management reports, forecasts and budgets what actually runs.
Verify
The account now carries the cost centre tag itself, separately from its group:
az storage account show --name az900lab1248213 --resource-group az900-lab12-rg --query tags.CostCenter -o tsv
Expected output: CC-1001.
az group show --name az900-lab12-rg --query tags.CostCenter -o tsv
Expected output: CC-1001.
az storage account show --name az900lab1248213 --resource-group az900-lab12-rg --query allowBlobPublicAccess -o tsv
Expected output: false.
Cost and clean-up
A Standard_LRS storage account with no data costs next to nothing while it exists, but charges are possible, so delete it today. Resource groups and tags are free. The pricing calculator is free and creates nothing in your subscription.
Created by this lab: the resource group az900-lab12-rg with its tags; the storage account az900lab1248213 (with your own digits) and its tags.
- Delete the resource group, which deletes the storage account
az900lab1248213and its tags with it. Leave lesson 1's budget exactly as it is: every later lab relies on it.
az group delete --name az900-lab12-rg --yes
- If you exported the pricing calculator estimate, delete the downloaded spreadsheet from your computer. It is not an Azure resource and costs nothing.
Check it is gone
az group exists --name az900-lab12-rg
Expected output: false.
Notes
The factors you should have seen move the calculator's figure: region (the same account costs different amounts in different regions), redundancy (GRS keeps extra copies in a second region, so it costs more than LRS) and access tier (cooler tiers store data for less, but charge more to read it). The estimate's name and the order of its items changed nothing, and neither do the names of resource groups or the number of tags.
If az tag update reports that the resource was not found, run the SA_ID= line again: Cloud Shell variables are lost when an idle session times out.
This is an independent study companion for the Microsoft Azure Fundamentals (AZ-900) exam and is not produced by or endorsed by Microsoft. Microsoft, Azure and Microsoft Entra are trademarks of the Microsoft group of companies.
This is an independent study companion for Microsoft Azure Fundamentals AZ-900 and is not produced by or endorsed by CompTIA.