Skip to main content

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​

ResourceTypeNotes
Resource groupazurerm_resource_group
User-assigned identityazurerm_user_assigned_identityNamed <agent_name>-id-<suffix>. Skipped when existing_managed_identity_id is set
Log Analytics workspaceazurerm_log_analytics_workspaceNamed law-<suffix>, SKU PerGB2018, 30 day retention
Application Insightsazurerm_application_insightsNamed ai-<suffix>, web, workspace-based. Skipped when existing_agent_app_insights_id is set
The agentazapi_resource, Microsoft.App/agents@2025-05-01-previewschema_validation_enabled = false, identity type SystemAssigned, UserAssigned
Connectorsazapi_resource, Microsoft.App/agents/connectors@2025-05-01-previewOne 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​

PropertyContents
knowledgeGraphConfiguration.identityThe user-assigned identity resource ID
knowledgeGraphConfiguration.managedResourcesResource group IDs built from target_resource_groups
actionConfiguration.accessLevelvar.access_level
actionConfiguration.identityThe user-assigned identity resource ID
actionConfiguration.modevar.action_mode
logConfiguration.applicationInsightsConfigurationappId and connectionString
upgradeChannelvar.upgrade_channel
monthlyAgentUnitLimitvar.monthly_agent_unit_limit
defaultModelprovider and name
experimentalSettingsEnableWorkspaceTools, EnableHttpTriggers, EnableV2AgentLoop, all set to true
vnetConfiguration.subnetResourceIdSet when vnet_subnet_id is not empty, otherwise the whole block is null
sandboxConfiguration.egressSet 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":

ConnectordataConnectorTypeData source
app-insightsAppInsightsThe Application Insights resource ID, plus appId in extendedProperties
log-analyticsLogAnalyticsThe workspace resource ID
azure-monitorAzureMonitorThe 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:

RoleDefinition ID
Readeracdd72a7-3385-48ef-bd42-f606fba81ae7
Log Analytics Reader73c42c96-874c-492b-b04d-ab87d138a893
Monitoring Reader43d0d8ad-25c7-4714-9337-8ba259a9fe05
Contributorb24988ac-6180-42a0-ab88-20f7382dd24c
SRE Agent Administratore79298df-d852-4c6d-84f9-5d13249d1e55

What gets assigned, all of it skippable with skip_role_assignments:

AssignmentPrincipalScope
Monitoring ReaderUser-assigned identityThe agent's resource group
SRE Agent AdministratorThe deploying user, as principal type UserThe agent resource
SRE Agent AdministratorUser-assigned identityThe agent resource
ReaderUser-assigned identityEach target resource group
Log Analytics ReaderUser-assigned identityEach target resource group
ContributorUser-assigned identityEach target resource group, only when access_level is High
Reader, Log Analytics ReaderSystem-assigned identityEach target resource group
ContributorSystem-assigned identityEach 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​

ArgumentRequiredValues and notes
nameYes2 to 32 letters, digits or hyphens, starting with a letter and ending with a letter or digit. Forces replacement
resource_group_name, locationYesForce replacement
identityYestype of SystemAssigned, UserAssigned, or SystemAssigned, UserAssigned, plus identity_ids when user-assigned is included. At least one identity must remain assigned
action_configurationOptional, computedaccess_level of Low or High, identity_id, and mode of Review or Autonomous
networkingOptional, computedegress_mode of AzureVNet, Limited or Unrestricted, with no provider default, and subnet_id, required with AzureVNet and omitted otherwise
resources_configurationOptional, computedidentity_id maps to knowledgeGraphConfiguration.identity, resource_ids maps to managedResources and must be non-empty
tagsOptional

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 on Azure/azure-rest-api-specs pull request 46278 and hashicorp/pandora pull request 5577. The PR changes no go.mod, go.sum or 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_configuration or resources_configuration preserves the remote value and reads it into state. There is no block reset, and action_configuration = [] style assignments are unsupported.
  • resource_ids must contain at least one ID. An empty set is invalid, never a request to clear scope.
  • The public API includes a ReadOnly action mode, which the draft preserves on read, import and discovery but cannot set. Only Review and Autonomous are configurable.
  • default_model is 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​