Prerequisites before the first deploy¶
Nothing in this repo deploys itself. CI does not log on to Azure. You deploy from your machine, after az deployment ... what-if.
Account and subscription¶
- Tenant:
<lab-tenant>.onmicrosoft.com(personal Microsoft account). - Subscription:
Azure subscription 1. - Azure CLI, logged in as the user that owns that subscription:
az login, thenaz account set --subscription "Azure subscription 1". - Bicep CLI 0.49.2 or newer, or
az bicep install. Check withbicep --version. - Replace
budgetContactEmailininfra/main.bicepparam(and in the vending parameter file if you use it). The committed value isreplace-me@example.com. - In Cost Management + Billing, note the remaining free-trial credit, the expiry, the billing currency, and whether a spending limit is on. Leave the spending limit on. When credit runs out, creation of some resources fails. That is the limit working.
Resource providers¶
The subscription deployment uses network, Log Analytics, diagnostics, and budgets. Register them once:
az provider register --namespace Microsoft.Network --wait
az provider register --namespace Microsoft.OperationalInsights --wait
az provider register --namespace Microsoft.Insights --wait
az provider register --namespace Microsoft.Consumption --wait
Microsoft.Authorization and Microsoft.Resources are already registered on a normal subscription.
Management groups need an elevation the subscription deploy does not¶
Creating management groups writes under the tenant root. On a personal Microsoft account tenant that switch is off until you turn it on. You can deploy infra/main.bicep (resource groups, network, policy, Log Analytics, budget) without doing this. Do this only when you are ready for infra/management-groups.bicep.
- The account must be a Global Administrator in
<lab-tenant>.onmicrosoft.com. The account that created the tenant is. - In the portal: Microsoft Entra ID → Properties → Access management for Azure resources = Yes. Save.
- Sign out and sign in again.
- Elevate from the CLI as well if the portal toggle and the CLI session disagree:
az rest --method post \
--url "/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01"
- Give yourself Owner at the root so you can create child management groups, not only User Access Administrator. Replace the object id with yours (
az ad signed-in-user show --query id -o tsv):
az role assignment create \
--role Owner \
--scope "/" \
--assignee-object-id "<your-object-id>" \
--assignee-principal-type User
- Register the provider and wait if the first call returns
TenantBackfillorHierarchyNotFound. The first management group operation builds the hierarchy and can take several minutes.
- Deploy the hierarchy with what-if first. Commands are in the README.
- When you are finished with tenant-wide administration, set Access management for Azure resources back to No. Owner on the
alzintermediate root is the ongoing right. Permanent User Access Administrator at/is more privilege than this lab needs.
Personal tenants sometimes hide Management groups until a subscription exists. This tenant has one, so the list should appear after elevation. If alz is already taken in the tenant, change prefix in infra/management-groups.bicepparam and update the docs in the same pull request. A later Azure Landing Zones accelerator deploy often uses its own prefix. Do not point both at the same names unless you mean to share the tree.
What you do not need¶
- No service principal and no client secret for day-to-day deploys.
- No GitHub secret for CI. The workflow only compiles Bicep.
- No Entra ID P2. PIM, access reviews, and Identity Protection are paid and are described in the identity design area, not deployed.
- No second subscription.
Suggested order¶
- Change the budget email.
az deployment sub what-ifforinfra/main.bicep. Read it. Then create.- Elevate, then what-if and create
infra/management-groups.bicep. - Leave the subscription where it is until you have read resource organisation. Moving it is a separate command and is not in the Bicep.
- Optionally what-if the vending module. With the default parameter file it creates a resource group and a small budget, not a subscription.