Azure SRE Agent Terraform reference
Two ways to define an agent as code, one that works today and one that does not exist yet. Microsoft's own template module drives Microsoft.App/agents through the azapi provider. A native azurerm_sre_agent resource is an open draft against the AzureRM provider, not merged and not in any release.
Values below are read from the module source and the draft's own documentation, on 14 September 2026. Both move: check the API version in the module and the state of the pull request before copying anything.
For what the agent is and what the settings mean, see Azure SRE Agent governance reference.
The azapi module
Source: sreagent-templates/terraform in the microsoft/sre-agent repository. It uses azapi for the agent because the resource is not in the azurerm provider, and azurerm for the resource group, identity, Log Analytics workspace, Application Insights and role assignments.
Resources it creates
| Resource | Type | Notes |
|---|---|---|
| Resource group | azurerm_resource_group | |
| User-assigned identity | azurerm_user_assigned_identity | Named <agent_name>-id-<suffix>. Skipped when existing_managed_identity_id is set |
| Log Analytics workspace | azurerm_log_analytics_workspace | Named law-<suffix>, SKU PerGB2018, 30 day retention |
| Application Insights | azurerm_application_insights | Named ai-<suffix>, web, workspace-based. Skipped when existing_agent_app_insights_id is set |
| The agent | azapi_resource, Microsoft.App/agents@2025-05-01-preview | schema_validation_enabled = false, identity type SystemAssigned, UserAssigned |
| Connectors | azapi_resource, Microsoft.App/agents/connectors@2025-05-01-preview | One per connector, parented to the agent |
The suffix is the first 13 characters of a SHA-256 over subscription ID, resource group name and agent name.
Agent body properties
| Property | Contents |
|---|---|
knowledgeGraphConfiguration.identity | The user-assigned identity resource ID |
knowledgeGraphConfiguration.managedResources | Resource group IDs built from target_resource_groups |
actionConfiguration.accessLevel | var.access_level |
actionConfiguration.identity | The user-assigned identity resource ID |
actionConfiguration.mode | var.action_mode |
logConfiguration.applicationInsightsConfiguration | appId and connectionString |
upgradeChannel | var.upgrade_channel |
monthlyAgentUnitLimit | var.monthly_agent_unit_limit |
defaultModel | provider and name |
experimentalSettings | EnableWorkspaceTools, EnableHttpTriggers, EnableV2AgentLoop, all set to true |
vnetConfiguration.subnetResourceId | Set when vnet_subnet_id is not empty, otherwise the whole block is null |
sandboxConfiguration.egress | Set when egress_mode is not Unrestricted, otherwise null |
The egress block carries mode, allowedHosts, allowedRegistries, allowedCodeRepositories and allowHttpMcpServerNetworkAccess. When the mode is AzureVNet it also carries a nested vnetConfiguration.usePrivateDnsResolution.
The API calls the action access level Low and High. The agent portal labels the same setting Reader and Privileged.
Connectors
Connectors stay on ARM, with typed properties rather than base64, because that path works for first-party and third-party tenants alike. The module can generate three from toggles, each with identity = "system":
| Connector | dataConnectorType | Data source |
|---|---|---|
app-insights | AppInsights | The Application Insights resource ID, plus appId in extendedProperties |
log-analytics | LogAnalytics | The workspace resource ID |
azure-monitor | AzureMonitor | The subscription ID, plus lookbackDays |
Anything in var.connectors is concatenated onto those.
Connector creation carries a 10 minute create, update and delete timeout, with a comment in the source explaining why: an ARM PUT on a connector triggers a Kubernetes extension install that can take 10 to 30 minutes or more, so the wait is capped deliberately. A timeout error is safe. Provisioning finishes in the background and a later apply reconciles state.
Skills, subagents, tools and common prompts are not ARM resources in this module. They are deployed through the data plane with apply-extras.sh, to avoid tenant restrictions that block third-party tenants.
Role assignments
Well-known role definition IDs are hard-coded in the module's locals:
| Role | Definition ID |
|---|---|
| Reader | acdd72a7-3385-48ef-bd42-f606fba81ae7 |
| Log Analytics Reader | 73c42c96-874c-492b-b04d-ab87d138a893 |
| Monitoring Reader | 43d0d8ad-25c7-4714-9337-8ba259a9fe05 |
| Contributor | b24988ac-6180-42a0-ab88-20f7382dd24c |
| SRE Agent Administrator | e79298df-d852-4c6d-84f9-5d13249d1e55 |
What gets assigned, all of it skippable with skip_role_assignments:
| Assignment | Principal | Scope |
|---|---|---|
| Monitoring Reader | User-assigned identity | The agent's resource group |
| SRE Agent Administrator | The deploying user, as principal type User | The agent resource |
| SRE Agent Administrator | User-assigned identity | The agent resource |
| Reader | User-assigned identity | Each target resource group |
| Log Analytics Reader | User-assigned identity | Each target resource group |
| Contributor | User-assigned identity | Each target resource group, only when access_level is High |
| Reader, Log Analytics Reader | System-assigned identity | Each target resource group |
| Contributor | System-assigned identity | Each target resource group, only when access_level is High |
The system-assigned identity gets the same roles as the user-assigned one because connector queries against Application Insights and Log Analytics run as the system identity. That is worth knowing before you audit role assignments and find two principals where you expected one.
The agent resource depends on the target role assignments, so the roles land before the agent comes up.
azurerm_sre_agent, in draft
Pull request 33411 against hashicorp/terraform-provider-azurerm, "New Resource: azurerm_sre_agent", opened 11 September 2026 by Dalibor Kovacevic. Status when read: open, draft, 29 files, labelled documentation, size/XL and ai-assisted. It adds a resource and a list resource of the same name, with CRUD, import, Terraform resource identity, list discovery, managed identity, tags, action configuration and managed-resource scope.
The author's own framing is that this is a preliminary draft, not ready to merge, with no reviewers requested. It depends on an unmerged API specification and an SDK that does not exist upstream yet, so nothing in it is usable from a released provider.
Proposed schema
| Argument | Required | Values and notes |
|---|---|---|
name | Yes | 2 to 32 letters, digits or hyphens, starting with a letter and ending with a letter or digit. Forces replacement |
resource_group_name, location | Yes | Force replacement |
identity | Yes | type of SystemAssigned, UserAssigned, or SystemAssigned, UserAssigned, plus identity_ids when user-assigned is included. At least one identity must remain assigned |
action_configuration | Optional, computed | access_level of Low or High, identity_id, and mode of Review or Autonomous |
networking | Optional, computed | egress_mode of AzureVNet, Limited or Unrestricted, with no provider default, and subnet_id, required with AzureVNet and omitted otherwise |
resources_configuration | Optional, computed | identity_id maps to knowledgeGraphConfiguration.identity, resource_ids maps to managedResources and must be non-empty |
tags | Optional |
Setting access_level does not create a role assignment, and neither identity_id reference grants anything. The provider creates no identities and no RBAC implicitly.
Exported attributes: id, endpoint, power_state, provisioning_state, running_state, a computed default_model block with name and provider, and principal_id and tenant_id on the identity block. Timeouts default to 30 minutes for create, update and delete, and 5 minutes for read.
terraform import azurerm_sre_agent.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-sre/providers/Microsoft.App/agents/example-sre-agent
Networking behaviour in the draft
Attaching is egress_mode = "AzureVNet" with subnet_id. Detaching means keeping the block, selecting a non-VNet mode such as Limited, and omitting subnet_id, which sends an explicit null vnetConfiguration and the new mode in one PATCH. Removing the whole block does not detach anything; it leaves the remote settings alone.
The subnet requirement matches the service: dedicated, in the agent's region, /27 or larger, delegated to Microsoft.App/environments. The draft's own example warns against assuming another agent's subnet has spare capacity or supports sharing.
Updates use selective PATCH rather than replacement, so settings the resource does not model stay untouched. Managed-path bypass settings are not exposed at all.
Stated limitations
- Networking targets the proposed stable API version
2026-10-01, which depends onAzure/azure-rest-api-specspull request 46278 andhashicorp/pandorapull request 5577. The PR changes nogo.mod,go.sumor vendor files, and upstream CI cannot build against the locally generated SDK. - DNS selector support is deferred. DNS values the API returns are neither sent back nor exposed as Terraform controls.
- Omitting
action_configurationorresources_configurationpreserves the remote value and reads it into state. There is no block reset, andaction_configuration = []style assignments are unsupported. resource_idsmust contain at least one ID. An empty set is invalid, never a request to clear scope.- The public API includes a
ReadOnlyaction mode, which the draft preserves on read, import and discovery but cannot set. OnlyReviewandAutonomousare configurable. default_modelis computed only. There is no model-selection setter.- AgentSpaces, connectors and implicit RBAC assignments are out of scope, as are VNet DNS, routes and firewall rules.
- No Azure acceptance tests, application tests or agent runtime tests ran against the October API version. Local validation covered 13 client and adapter cases on Go 1.26.6.
Until it merges, the azapi path above is the one that deploys.
Sources
microsoft/sre-agent,sreagent-templates/terraform/main.tf, read 14 September 2026.- hashicorp/terraform-provider-azurerm pull request 33411, including the proposed
website/docs/r/sre_agent.html.markdown, read 14 September 2026. - Agent permissions on Microsoft Learn, for the roles behind
access_level.