AI & Cloud Automation
What can your AI agent do when it ignores you?
Not if it ignores you. When. Instructions are a request, and a good agent follows most of them. “Most” is the problem.
To find out, I built a simulation in my lab: an autonomous Azure remediation system, turned loose on a lab tenant with dev, QA and production subscriptions seeded with compliance failures. The first version had one identity and a lot of confidence.
The first time I watched it work through its queue, it was daunting. The agent had pulled every object from the compliance failures database into the console and started classifying them. It was rating production objects as risk level 1, which meant remediation with no human involved. It was lining up fixes for objects Terraform owned, which the next pipeline run would have undone. Production VMs were queued to be stopped, and production Key Vaults were queued for network lockdown. All lab resources, which is the only reason this story is funny.
The fixer agent had already started. It had set an Application Insights object to private without linking it to the AMPLS. It had set a Key Vault to private with a private endpoint. It was moving fast.
I hit the kill switch.
I had rushed it, and the queue showed me exactly where. The damage was small and entirely inside the lab: a couple of Key Vaults in the dev subscription, a storage account in QA and that one Application Insights object. No VM in the simulated production subscription was touched. The registry had written down every action, so I knew exactly what had changed.
Then I started over. Here's the pattern that fixed it.
Instructions are the leash. Permissions are the wall.
An instruction tells an agent what it should do. A permission decides what it can do. Getting an agent to obey is the first job. Making sure it can't cause damage when it strays is the second. A system that is safe only while the agent behaves isn't safe. Seeing what it did is the third job, and I'll get to that.
The pattern
Five rules. The detail follows.
- One function, one identity. Split read from write.
- Agents read a record, not the tenant. The risk level is set before they see it.
- Tier the risk. Humans own the top tiers.
- Brief the agent like a new hire. Vague instructions get improvised.
- Log it where it can't be edited. Keep a stop button.
1. One function, one identity
The early version ran everything under a single identity. Anything any part of the system needed to do, that identity could do. One identity that can do everything is the agent equivalent of standing Owner access.
Then I tried to read its audit logs, and it was frustrating. Everything happened under the same identity, so every read, classification and remediation blended into one activity trail. I could see what happened, but working out why, or which function triggered it, took far longer than it should have. There was nothing specific to build an alert around.
Now each module has its own identity, and each module gets two: one that reads and one that writes. Both use federated credentials, and each carries a custom role scoped to the single function it performs and nothing wider.
The read identity can't change anything. The write identity has a short list of things it should ever do. That is least privilege applied to something that can act on its own.
2. Agents read a record, not the tenant
The agents never query Azure directly. A set of PowerShell scripts walks every subscription and writes each compliance failure into a Cosmos DB database, along with what the agent needs to know: environment (prod, QA or dev), owning team, the infrastructure as code repo if there is one, and a risk level.
In the early version the agent graded its own risk. Now the scripts assign the risk level when they write the record. The agents have read-only access to that database, so they can read the risk level and can't change it. An agent shouldn't grade its own homework.
The system that collects information and the system that acts on it should not be the same thing. The more control an agent has over its own inputs, the harder its decisions are to trust.
3. Tier the risk, and make humans own the top tiers
Every finding carries a risk level. The risk level sets how much autonomy the agent gets, not what the fix is. The fix comes from a decision tree a human wrote.
Level 1 can be remediated with no one watching, but only where no infrastructure as code is detected. If IaC owns the object, the agent opens a pull request instead. Levels 2 and 3 always need a human, and at level 3 the human also supplies the instructions. Production needs approval by default.
Then came a dev object. The agent rated its blast radius zero and found no activity in 30 days. It had no IaC, it lived in dev and it looked unused. It sat at risk level 1, so no human was in the middle. The agent recommended deleting it.
The custom role on its identity had no delete permission. The agent stopped. I hadn't anticipated that action. The role didn't include it.
That is why the decision tree exists. Once the agent started reaching for fixes like that, a human-written tree came next: every type of compliance failure, mapped against environment and factors like IaC, with a defined solution for each.
4. Brief the agent like a new hire
Write the instructions as if the agent were a brand-new employee who doesn't know the ropes yet. What can it see? Which identity does it use to read, and which to write? What happens at each risk level? Who wins when two rules disagree?
Mine starts with the role and a limit: “You do not invent remediation strategies. You execute the strategies humans have documented, within the autonomy limits set by the risk level.”
It then lists its sources of truth in order of precedence and re-reads the decision tree at the start of every run. The tiebreaker is one line: “If sources conflict, the most restrictive interpretation wins.”
A new hire with vague instructions improvises. So does an agent.
In the early version, every ambiguity became a decision the agent had to make for itself. The more room I left for interpretation, the more unpredictable the results became.
5. Log it where it can't be edited, and keep a stop button
The unreadable log taught me something most AI governance advice skips: if you can't see what an agent did, you can't govern it. Logging and auditing are what turn a bad action into an alert.
Every module's agents write every action to a registry in a separate Postgres database. The agents get SELECT and INSERT grants and nothing else. They can read the registry and add to it. They can never modify or delete an entry.
That holds against the agents. It isn't a promise about someone with owner or admin rights on the database, so the agents' role should never own the table.
The last piece is a stop button. The console has a kill switch that sets every workload to zero replicas. Pods shut down gracefully, and nothing autonomous runs again until someone turns it back on. I used it on that first run.
What surprised me
What surprised me was how much safer I felt once the boundaries were tight. The safety didn't come from what I'd told the agents. It came from what they couldn't do.
Auditing got easier too. The trail that used to be unreadable now has a dedicated identity attached to every action. Alerting did as well: a write by one module's fixer against another module's resource is no longer just another entry in the log.
The test. Assume every instruction fails tomorrow. What's the worst thing this identity can still do?
Do this Monday
- List every identity your agents use. Split any that both read and write, and cut each role down to the one function it performs
- Point agents at a read-only record of the data, not the live tenant
- Give every finding a risk level. Decide which levels need a human, and make production one of them by default
- Write the agent's instructions for a new hire, with a tiebreaker: when rules conflict, the most restrictive wins
- Send every action to a log the agents can add to but never change
- Test the stop button before you need it
It is easier to set the boundaries before an agent is running than after your first scary queue. My secure Azure AI deployment work starts with exactly that: scoped identity, full logging and guardrails in place before anything runs.
Want the deeper technical version?
The member library holds the verification checklists, the Azure Resource Graph and Entra queries, and the architecture references behind these articles.
Get practical Azure insights
Occasional technical guidance on Azure architecture, security, governance, cost optimization and cloud operations. No drip sequences, no sales cadence.