I’ve had the benefit of stepping in to other developers’ Azure accounts, and it’s very much like opening up someones brain and taking a peek inside.
There are some bits ordered here and there, but it’s mostly chaos.
If it’s setup by someone with experience you will notice an intention of following conventions because they’ve seen first hand how quickly it gets out of hand. When there are more than one contributor, you will start noticing different patterns depending on which person set it up.
That is why it is so important to document a convention.
Why is it like this?
- Most Azure resources are hard to move and rename. If you do something wrong you will need to delete and recreate the resource which often isn’t worth the trouble.
Here follows my convention. If you don’t like it, feel free to create your own. The most important thing is not how resources are named, but that the convention is followed so they’re named the same way.
Microsoft will suggest you to put production and non-production resources into different subscriptions, in order to take advantage of Azure Dev/Test offer. I’m not in favour of this approach.
I want you to think about the subscription as “who gets the invoice?”. Not which department is going to bear the cost, but the actual invoice. Depending on your organization structure you need 1 subscription, or you’ll need 10.
It is not uncommon to have one financial department that will receive the invoice and split the costs on different cost units. It is also not uncommon to have 4 different legal entities and invoicing them separately.
If you as a consultant are doing work for a client that doesn’t have their own subscription, create a subscription for them. You will have all the costs neatly gathered, and you can easily hand it over when the project is done.
I structure my resource groups like this.
Let’s unpack this a bit
- Project Name, is the name of the application, project, website. I place this first, because when I’m searching for a resource group I will always start looking for the name of the application.
- Component Name, is optional. Sometimes you don’t need it, but most of the time there are several components in a project. A web, an API, a BI component.
- Environment, will be dev, test, stage or prod. I place different environments in different resource groups to make it easier to tear down one environment and rebuild another. It helps with keeping environments isolated and access control on the environment level.
- Rg, to make it easier to recognise a resource group in
az cliand other API scenarios.
A note on isolating environments. It drive cost up when you won’t share app service plans between dev and test. In my experience dev/test resources are cheap and it doesn’t cost much to duplicate them. The benefit of completely isolated environments is greater than the cost of split resources.
In my small Klabbet subscription it looks like this.
This scales well with hundreds of resource groups thanks to the filter functionality. Writing
vaccinated in the filter box, will help me to quickly identify all resource groups belonging to that project.
Now we’ve made sure each resource group only contains resources for a specific application, component, environment. It will make the number of resources in each group much fewer and easier to overview.
I have a naming convention for azure resources as well. (looks very much like the previous one)
Project name, component name and environment in the resource name is useful for working with
az cli and Azure APIs. The resource name abbreviation should be picked for the Microsoft recommended abbreviations. If your resource doesn’t have an official abbreviation, make your own and document it in your convention.
Don’t worry about Microsoft having special naming constraints, just remove the dashes for storage accounts.
Here’s what a resource group might look like.
Tagging is often forgotten, even if you’re reminded every time you create a new resource. *hint* *hint* Tagging is extremely useful. Here are my standard tags that I put on all resources.
|Application||Vaccinated||Boss comes in and say: “I want to know exactly how much this project has cost us.” You filter cost analysis on the Application tag.|
|Environment||prod||Being able to split cost analysis on different environments is golden.|
|Organization||Klabbet||You will always host only 1 organization within this subscription, until you’re not. When you’re going to create that first cost report, you’ll be glad that you did tag Organization from the start.|
Other suggested tags “Business Unit”, “Component”, “Country” if you have an org with different departments, work on different components or is multi-national.
Tagging is for reporting, so make sure that you think of what your boss might come ask of you when you setup which tags are mandatory.
Now we can filter or group our expense reports on these tags.
This blog post has been going through my preferred way of getting order in my Azure account, making it easy to find things and tagging things to make reporting easier.
This might not be your preferred way, but it is has proven itself useful to me.