Appearance
13.5 — Azure in Practice
Azure is Microsoft's cloud. Anything you create in it is called a resource: a virtual machine, a database, a storage account. Many resources are protected by an access key, which is a long secret string that works like a password. An application that presents the key is let in.
Every Azure resource that uses keys gives you two of them, called Key 1 and Key 2, and both work. New users assume one is a backup.
There are two so that you can change a key without any downtime. Replacing a secret with a fresh one is called rotation, and you should do it regularly in case the old one has leaked. With one key, there would be a gap: the moment you replace it, every application still holding the old key is locked out. With two keys there is no gap. The steps are:
- Your applications are using Key 1.
- You generate a fresh Key 2.
- You change your applications' settings so that they use Key 2.
- You check that nothing uses Key 1 any more.
- You generate a fresh Key 1. It is now the spare for next time.
Chapter 8.6.1 called this pattern expand and contract. Azure has built it into the product.
An even better answer is to use neither key, and section 4 shows how. Azure prefers to control access by who is asking, and not by which secret they hold. This matters for every other section on this page.
1. The hierarchy, and what each level is for
Tenant (one Entra ID directory — the identity boundary)
└── Management group policy and access, applied to many subscriptions
└── Subscription billing boundary and quota boundary
└── Resource group lifecycle boundary
└── ResourceAzure arranges everything as boxes inside boxes, as the listing shows. Each level exists for a different reason. A common design mistake is to use one level for a job that belongs to another. Take them from the top.
The tenant decides who exists. A tenant is one company's copy of Entra ID. Entra ID is Microsoft's directory of users, groups and applications, and it is the service that logs people in (Chapter 8.4.9). Everything inside one tenant shares the same users and groups.
A subscription decides who pays and how much you may create. Each subscription gets its own bill. Each one also has its own quotas. A quota is a cap on how much of something you may create, for example how many CPU cores in one region. This gives a good reason to put production and development in separate subscriptions. If a developer's experiment uses up the development quota, production is not affected, because its quota is separate. That is a stronger reason than having separate invoices.
A resource group decides what gets deleted together. This is the level you deal with every day. Deleting a resource group deletes everything inside it. So put things in the same group when they are created and removed together. One application's website, database and storage make a good group. Never put something shared, such as the company's network, into one application's group, because deleting that application would delete it too. As a safeguard, you can put a resource lock on a resource. A CanNotDelete lock blocks deletion. A ReadOnly lock blocks deletion and changes.
A management group holds several subscriptions. A rule or a permission set on the management group applies to every subscription inside it. That is how a large company states a rule once and has it apply everywhere.
2. Control plane and data plane
There are two different things you can do with a resource. You can manage it, and you can use it. Azure keeps the two apart, and mixing them up causes real mistakes.
The control plane is for managing. Creating a storage account, changing its settings and deleting it are control-plane actions. They all go through one service, called Azure Resource Manager. It checks your permissions and records what you did in the activity log.
The data plane is for using. Reading a file from that storage account, running a query on a database and sending a message to a queue are data-plane actions. They go to a different address, they are checked by a different set of permissions, and they are recorded in different logs.
Here is the mistake this leads to. Permissions in Azure are handed out as roles, and a role is a named bundle of permissions. The role called Contributor is a control-plane role. It lets a person manage a storage account. It gives no permission to read the files inside. (A file in Azure storage is called a blob.) So it looks safe to give Contributor to someone who must not see the data.
It is not safe. Showing the account's access keys counts as a management action, so a Contributor can do it. With a key in hand, that person can read, change and delete every blob. Contributor therefore gives access to the data through a side door.
The correct way to let someone read blobs is a data-plane role, called Storage Blob Data Reader. And to close the side door, turn off access by key on the account altogether, with the setting allowSharedKeyAccess: false. After that, the only way in is by identity, and the roles mean exactly what they say.
Two more things to know about the control plane.
Each kind of resource is supplied by a part of Azure called a resource provider. A resource provider has to be switched on, or registered, in a subscription before it can be used there. If your first deployment fails with "resource provider not registered", this is why. It has nothing to do with your permissions.
The control plane also limits how fast you may call it. Limiting the rate of requests like this is called throttling. A script that creates hundreds of resources in a tight loop will hit the limit. Send the requests in groups, and wait a little longer after each refusal.
3. Access control
A role assignment has three parts: who, what and where. The principal is who gets the permission. It can be a user, a group or an application. The role is what they may do. The scope is where it applies: one resource, a resource group, a subscription or a management group. This is the role-based access control (RBAC) of Chapter 8.4.10. An assignment also applies to everything inside its scope. A role given on a subscription applies to every resource group in that subscription.
Use the roles Azure already provides. Write your own role only when none of them fits, and give it as few permissions as possible.
Give roles to groups, not to individual people. When someone joins or leaves a team, you change the group's membership once. You do not have to edit dozens of assignments. The automatic account provisioning of Chapter 8.4.6 can even do it for you.
Privileged Identity Management, or PIM, gives out powerful roles only for a short time. Without it, an administrator holds administrator rights every hour of every day. With PIM, the person is only eligible for the role. When they need it, they activate it for a few hours and state the reason. You can also require someone else to approve the request. Afterwards the rights go away again. So for most of the day nobody holds powerful rights, and a stolen password is worth far less. Chapter 8.4.10 called this removing standing privilege. PIM is the most valuable access control Azure has.
Azure Policy lets you write rules that Azure enforces on every deployment. A person cannot check every resource in a large company, so the rules are written down and Azure checks them. Here is a rule that allows resources only in the two UK regions:
json
{ "if": { "field": "location", "notIn": ["uksouth", "ukwest"] },
"then": { "effect": "deny" } }Read it as a sentence. If the resource's location is not uksouth and not ukwest, then refuse to create it.
The effect says what happens when a resource matches the rule. There are four you will use.
denyblocks the deployment.auditlets the deployment through and records that it broke the rule.deployIfNotExistsfixes the problem automatically by deploying what is missing. A common use is switching on logging for every new resource.modifyadds or changes a property on the resource, such as a required tag.
Start every new policy as audit. Look at what it would have blocked. Only then switch it to deny. A company's existing systems always contain things nobody remembered. If you start with deny, you break deployments that nobody expected to be affected.
A landing zone is all of the above set up in advance. It is a ready-made arrangement of subscriptions, networks, policies and logging that every new project starts from. Microsoft publishes one. Even if you build your own, its layout is worth following.
4. Identity instead of secrets
Chapter 8.6.1 argued that the safest secret is one that does not exist. This is how Azure does it.
A managed identity gives a resource its own identity in Entra ID. Take a web application that needs to read from a storage account. With keys, you would have to put the storage key into the application's settings, where it could leak. With a managed identity, the web application itself becomes a principal, like a user. You give that principal the Storage Blob Data Reader role. Azure then proves the application's identity to the storage account behind the scenes. No password or key is stored anywhere (Chapter 8.4.9).
There are two kinds. A system-assigned identity belongs to one resource and is deleted with it. A user-assigned identity is created separately and attached to the resource. Prefer user-assigned. Automated deployments often delete a resource and create it again. A user-assigned identity survives that, and so do its role assignments.
Key Vault is the service for the secrets that you cannot avoid. Examples are the API key of an outside company's service, certificates and encryption keys. Three details about it matter in practice.
Deleted items are kept for a while, and you cannot turn that off. This is called soft delete. A deleted vault or secret can be restored during a retention period, which is 90 days by default. A second setting, purge protection, stops anyone from wiping a deleted item for good before that period ends. Together they protect the keys that decrypt your data from being destroyed, by accident or by an attacker. There is a side effect. The name of a deleted vault stays taken. A deployment that deletes a vault and creates a new one with the same name will fail until the old one has been purged. This error is common, and the message does not make the cause obvious.
Control access to the vault with roles. Key Vault also has an older system of its own, called access policies. Access policies are set on each vault separately, they are hard to review, and they cannot be set once on a management group. Use the role-based model.
Let Key Vault manage your certificates. Few teams use this feature. Key Vault can store a certificate and renew it automatically before it expires. Other Azure services, such as App Service, which hosts websites, can read the certificate straight from the vault. That removes the outage Chapter 8.3.1 described, in which a site goes down because somebody forgot to renew a certificate.
5. Microsoft Graph
Microsoft 365 is the package of office products a company rents from Microsoft: Outlook for email, Teams for chat and meetings, SharePoint and OneDrive for files. Microsoft Graph is one API that reaches all of them. Through a single address, graph.microsoft.com, a program can read and change users, groups, mail, calendars, files, Teams messages and device records.
A program can hold a permission in two ways (Chapter 8.4.9). A delegated permission lets the program act for the user who is signed in, and it can see only what that user can see. An application permission lets the program act as itself, with no user present. The difference is large. Mail.Read as a delegated permission reads the signed-in user's mail. Mail.Read as an application permission reads every mailbox in the company.
Three things limit what you can do with Graph. For most of its APIs, none of the three is a bill.
The first limit is throttling, and you will meet it most often. Graph allows each application a certain number of requests in each tenant. Outlook, SharePoint and Teams each have their own separate limits. When you go over, Graph answers with the status code 429, which means "too many requests". The answer carries a header called Retry-After that says how many seconds to wait. Wait exactly as long as that header says. Do not invent your own waiting scheme. Spread your requests out over time. And remember that a tenant also has a total budget, shared by every application running in it. Some of those applications belong to other companies, and you have no control over them.
The second limit is licensing. Some data can be read only if the tenant's users hold a particular paid licence. So an API call that works in your own test tenant can fail in a customer's tenant. No change to your code fixes that. The customer has to buy the licence.
Metering is the third, and it has changed. For several years, some Teams APIs were billed per message against an Azure subscription. The message export API used by backup and compliance products was the best-known one. Microsoft stopped metering those Teams APIs on 25 August 2025, and the billing setup they needed is no longer required. You will still see the old warning in older documentation and in some vendors' products. The lesson that lasts is to check the current metering page for any API you build a product on, because Microsoft has both added and removed per-unit charges on Graph over time.
Three practices that avoid most of the trouble:
Delta queries. The first time, you fetch everything, and Graph gives you a token that marks that moment. Next time you send the token back, and Graph returns only what has changed since. This needs far fewer requests than listing everything again.
Change notifications. You give Graph a web address of your own, and Graph calls it when something changes. A call like this is known as a webhook. It replaces polling, which means asking over and over whether anything is new. Two duties come with it. Each subscription expires, so renew it in time. And check that every notification really came from Microsoft (Chapter 5.8 has the checklist).
Batching. You can pack up to 20 requests into one call. That saves time, and it helps you stay under the throttling limits.
6. Azure AI services
Azure rents out ready-made AI models that you call over the web. There are services for turning speech into text, for understanding images, for translating, and for reading scanned documents. There is a service that checks content for harm. And Azure hosts the large language models made by OpenAI.
The names keep changing, so learn the current ones. These used to be called Cognitive Services, then Azure AI services. The portal for building with them was Azure AI Studio, renamed Azure AI Foundry in late 2024, and renamed again to Microsoft Foundry at Microsoft's Ignite conference in November 2025. The Azure OpenAI Service now lives inside Foundry, where OpenAI's models are listed alongside models from other companies. The ideas below are the same under every name.
What is genuinely different from calling a public API:
You call a deployment, not a model. First you create a deployment: your own named copy of a model, in a region you choose. Your code then calls it by the name you gave it. Each region offers a different set of models. If you move to another region, the model you were using may not be there.
Quota is counted in tokens per minute. A token is a piece of a word, and it is the unit in which a language model's work is measured (Part 12). Your quota is set separately for each subscription, each region and each model. In practice the quota stops you long before the price does. A product launch fails because nobody asked for more quota weeks earlier, and an increase has to be requested and approved. So plan your quota the way you would plan servers.
Provisioned throughput is the other way to buy. You reserve a fixed amount of model capacity for yourself. Response times become steady, and you pay for the reserved capacity whether you use it or not. It is worth it only when your usage is high all the time.
Large companies usually choose Azure for its promises about data. There are three. What you send to the model and what it answers are not used to train models. Your data stays in the region you chose. And a private endpoint keeps the traffic off the internet. For a bank or a hospital, these promises often decide the matter, more than how good the model is.
Content filters check what goes into the model and what comes out. You can set how strict they are, and with Microsoft's approval you can loosen them. Sometimes a filter blocks something harmless. Chapter 12.14.3 calls this over-refusal. So your code should treat a filtered answer as a case of its own and show the user a clear message. Do not treat it as a crash.
Prompt flow was the tool for chaining prompts, code and model calls into a flow, then testing that flow against sample data (Chapter 12.8.7). Microsoft has announced that Prompt flow will be retired on 20 April 2027, in both Foundry and Azure Machine Learning. Its stated replacement is the Microsoft Agent Framework, a code library rather than a visual designer. So do not start new work on Prompt flow. If you inherit some, plan its move before that date.
Content safety as a standalone service is worth knowing separately: it classifies text and images for harm categories, which is the guardrail layer of Chapter 12.10.8 available as an API.
7. Operating an Azure estate
Azure Monitor and Log Analytics collect measurements and logs from your resources into one store, called a workspace. You search the workspace with a query language named KQL, the Kusto Query Language. Here is a query that finds what failed in the last hour:
kusto
AppRequests
| where TimeGenerated > ago(1h) and Success == false
| summarize failures = count() by Name, ResultCode
| order by failures descRead the query one line at a time. Each | passes the result of one line to the next. Line 1 starts from the table of web requests. Line 2 keeps the requests from the last hour that failed. Line 3 counts them, grouped by request name and result code. Line 4 puts the largest count first.
A resource sends no logs anywhere until you tell it to. The instruction is called a diagnostic setting, and each resource needs its own. It is off by default. Most teams find this out during an outage, at the moment they go looking for the logs. The fix is a deployIfNotExists policy that turns the setting on for every new resource. It is the best example of what that policy effect is for.
Cost Management shows what you are spending. Set a budget and an alert for unusual spending. Use a policy to put tags on every resource, so that each cost can be traced to a team (Chapter 13.1).
Names have strict rules, and many cannot be changed later. A storage account's name must be unique across all of Azure. It must be lower-case, 3 to 24 characters long, with no hyphens. Many resources cannot be renamed at all. And as section 4 showed, some names stay taken after you delete the resource. So agree on a naming scheme before your first deployment. Changing a name later means deleting the resource and creating it again.
Region capacity is real. A specific virtual machine size or GPU family can be unavailable in a region, and the error appears at deployment. Check availability before designing around a size, and have a second region in mind.
What the interviewer will push on
"Why does Azure give you two keys?" Zero-downtime rotation: use one, regenerate the other, move configuration, confirm nothing uses the old one, then regenerate it as the new spare. Then give the better answer — use a managed identity and disable key-based access entirely, so there is no secret to rotate.
"Someone has Contributor on a storage account. Can they read the data?" Yes — indirectly. Contributor is a control-plane role with no data permission, and it can list the account keys, which grant full data access. The correct grant is a data-plane role such as Storage Blob Data Reader, with shared-key access disabled so the side door is closed.
"What is a resource group for?" A lifecycle boundary — deleting it deletes everything inside. Group what lives and dies together, never put shared infrastructure in an application's group, and use resource locks against accidental cascade. Subscriptions are the billing and quota boundary, which is the better reason to split production from development.
"How would you enforce that all resources are deployed only in the UK?" Azure Policy with a deny effect at a management group. Then the operational detail that shows experience: start in audit, review what it would have blocked, then switch to deny — going straight to deny on a live estate breaks deployments nobody predicted.
"What limits a Microsoft Graph integration?" Throttling first — per application per tenant per service, shared with other applications you do not control, and Retry-After must be honoured. Then licensing, which makes an API work in your tenant and fail in a customer's. Then metering: some Teams APIs used to be billed per message, and Microsoft stopped that in August 2025. Knowing it changed, and checking the current metering page before you design, is the answer that shows you work with it.
"What is the constraint on Azure OpenAI (now part of Microsoft Foundry) in practice?" Tokens-per-minute quota per subscription, region and model — requested ahead, not provisioned on demand. Plan it like capacity. Then mention the reasons enterprises pick it: regional data residency, no training on your data, private endpoints, and configurable content filters.
One thing to volunteer: point out that Key Vault soft delete reserves the vault name during the retention window, so a pipeline that deletes and recreates a vault with the same name fails until it is purged. It is a small operational detail that produces a genuinely baffling deployment error, and knowing it signals you have run this rather than read about it.
Recall
- Tenant (identity) → management group (policy) → subscription (billing and quota) → resource group (lifecycle) → resource. Deleting a resource group deletes everything in it — group what lives and dies together, and use resource locks.
- Control plane (Resource Manager) and data plane are separate permission models. Contributor can list account keys and therefore read data — grant a data-plane role and disable shared-key access.
- Role assignments are (principal, role, scope) and inherit downward. Assign to groups; use Privileged Identity Management for just-in-time elevation — the practical way to remove standing privilege.
- Azure Policy is guardrails as code:
deny,audit,deployIfNotExists,modify. Always start inauditand switch todenyafter reviewing what it would have blocked. - Two keys exist for zero-downtime rotation — expand and contract. The better answer is a managed identity with no key at all. Key Vault has non-optional soft delete plus purge protection, which reserves the name and breaks recreate-with-the-same-name pipelines.
- Graph's cost model is throttling first (per application per tenant per service, shared, honour
Retry-After), licensing second (works in your tenant, fails in a customer's), and metering third — the per-message Teams API charges ended in August 2025, so check the current page. Use delta queries, change notifications and batching. - Azure OpenAI: deployments, not models; quota is tokens per minute per subscription, region and model, and is the binding constraint. Enterprises choose it for residency, no-training commitments, private endpoints and content filters — and a filtered response is a distinct case, not an error.
- Diagnostic settings are off by default — enable them everywhere with
deployIfNotExists. Decide naming conventions first: many resources cannot be renamed and some names are reserved after deletion.
Self-test: What is the actual purpose of Key 1 and Key 2? · How does Contributor end up reading blob data? · Which boundary is billing and quota, and which is lifecycle? · What is the safe rollout order for a new policy? · Name the three parts of Graph's cost model · What is the practical limit on an Azure OpenAI launch?
Next: you now know what you can rent. 13.7 covers how your code gets there. It explains the pipelines that build and ship software automatically, using GitHub Actions, Jenkins and Azure DevOps, and it ends with a complete CI/CD lab you can run for free on your own machine. Those pipelines assume you know Git. If you have not used Git before, read 13.11.1 to 13.11.3 first and then come back. Containers and Kubernetes, which pipelines usually deliver to, have a Part of their own, starting at 14.0.