agentleFS
soulemikesoulemike/microsoft-skills/skills/azure/SKILL.md

azure

Skill2 starsChanged 3 months agoMITView on GitHub

Use this skill for Azure Resource Manager authentication and REST automation with sovereign cloud support, pagination, and async operation tracking.

9 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when an agent needs an ARM-scoped token and a safe REST wrapper for Azure management-plane work.

    line 22
  2. Very specific:

    Prefer ManagedIdentity or Federated authentication.

    line 65
  3. Distinctive:

    Treat async completion as incomplete until the returned operation endpoint reports success.

    line 67
  4. Distinctive:

    Run a PUT that returns async metadata (capture operation URLs)

    line 121

“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Azure Resource Manager Skill

Agent Summary

Use this skill when an agent needs an ARM-scoped token and a safe REST wrapper for Azure management-plane work. Create a context with Connect-AzureApi.ps1, then pass that context to Invoke-AzureRestMethod.ps1 for Azure subscriptions, resource groups, providers, or async operation polling.

When to Use

  • List, read, create, update, or delete Azure resources through ARM.
  • Work in Azure commercial, US Gov, or China without rewriting endpoints.
  • Capture Azure-AsyncOperation, Operation-Location, or Location headers for long-running operations.

Required Parameters

Connect-AzureApi.ps1

ParameterTypeRequiredNotes
EnvironmentstringYesAzureCloud, AzureUSGovernment, or AzureChinaCloud.
AuthenticationTypestringConditionalManagedIdentity, Federated, Certificate, or ClientCredentials.
TenantIdstringConditionalRequired for Federated, Certificate, and ClientCredentials.
ClientIdstringConditionalRequired for Federated, Certificate, and ClientCredentials; optional for user-assigned managed identity.
FederatedTokenstringConditionalRequired for Federated.
CertificatePathstringConditionalRequired for Certificate.
ClientSecretSecureStringConditionalRequired for ClientCredentials.
SubscriptionIdstringNoRecommended when later ARM calls are subscription-scoped.

Invoke-AzureRestMethod.ps1

ParameterTypeRequiredNotes
UristringYesRelative ARM path or absolute ARM URL.
AuthContextobjectYesOutput from Connect-AzureApi.ps1.
MethodstringNoDefaults to GET.
ApiVersionstringNoStrongly recommended for ARM resources.
BodyobjectNoRequest payload for writes.
PaginateswitchNoEnumerates GET pagination.

Example Agent Prompts

  • "List all resource groups in this Azure subscription."
  • "Create a storage account through ARM and capture the async operation URL."
  • "Call an Azure REST endpoint directly when there is no SDK wrapper."

Example Agent Workflow

$ctx = ./skills/azure/Connect-AzureApi.ps1 -AuthenticationType ManagedIdentity -Environment AzureCloud -SubscriptionId $env:SUBSCRIPTION_ID

$groups = ./skills/azure/Invoke-AzureRestMethod.ps1 -Uri "/subscriptions/$($ctx.SubscriptionId)/resourcegroups" -ApiVersion "2021-04-01" -AuthContext $ctx -Paginate

Security Caveats

  • Prefer ManagedIdentity or Federated authentication; never default to client secrets.
  • Scope RBAC as narrowly as possible at the subscription, resource group, or resource level.
  • Treat async completion as incomplete until the returned operation endpoint reports success.

Overview

This skill set covers Azure Resource Manager (ARM) authentication and REST calls for sovereign cloud aware automation. Use Connect-AzureApi.ps1 to build an ARM context, then Invoke-AzureRestMethod.ps1 to execute and track ARM operations.

Authentication

  • Auth types for ARM: ManagedIdentity, Federated (OIDC), Certificate, ClientCredentials (client secret).
  • Token audience: https://management.azure.com/ (use the environment's ARM endpoint, for example https://management.usgovcloudapi.net or https://management.chinacloudapi.cn).
  • Notes on service principal vs managed identity for ARM
    • Service principal (certificate or client secret) uses Entra ID app authentication and must have appropriate RBAC permissions on the target scope.
    • Managed identity avoids credential material and relies on the platform to obtain the ARM token via IMDS or the local identity endpoint.

Endpoints

Skills

FilePurpose
Connect-AzureApi.ps1Resolves the ARM endpoint for the selected environment and acquires a token using the normalized auth parameter set, returning a consistent ARM context (Token, ExpiresOn, TenantId, ClientId, ArmEndpoint/BaseUri).
Invoke-AzureRestMethod.ps1Executes ARM REST requests from a relative ARM URI (or full URL), adds api-version when provided, supports GET pagination via -Paginate, and captures async operation headers (Operation-Location, Azure-AsyncOperation, Location) for polling.
auth/*.ps1Thin wrappers around Connect-AzureApi.ps1 for common auth shapes: ManagedIdentity.ps1, FederatedCredentials.ps1 (OIDC), and ServicePrincipal.ps1 (certificate or client secret).

Toolchain

ToolBest ForToken AudienceLimitations in ARM Context
Azure CLI (az)Cross-platform scripting, Bicep/ARM deployment, quick ad-hoc commandshttps://management.azure.com/ by defaultNot available in all execution contexts (e.g., restricted containers); output parsing can be brittle
Az PowerShell modules (Az.*)Native PowerShell pipelines, object-oriented output, Azure Resource Graphhttps://management.azure.com/ by defaultHeavy module dependency tree; version conflicts between Az and Microsoft.Graph modules can occur. Mitigate with DllPickle or ./prerequisites/Import-ConflictSafeModules.ps1. See docs/dll-conflict-mitigation.md.
Bicep / ARM TemplatesDeclarative infrastructure; what-if validation; policy-driven complianceARM deployment identity (service principal or managed identity)Imperative logic (loops, conditionals) is limited; no direct Graph or Dataverse integration
Raw REST (Invoke-RestMethod)Full control over headers, body, and URI for custom ARM operationshttps://management.azure.com/Caller must handle pagination, throttling, retry logic, and token refresh manually

Patterns & Caveats

  • Async operations (Azure-AsyncOperation header)
  • Subscription scoping
  • api-version requirements
  • ARM template deployment vs direct REST

Examples

  1. List resource groups (GET, with pagination)
$ctx = ./skills/azure/Connect-AzureApi.ps1 -AuthenticationType ManagedIdentity -Environment AzureCloud -SubscriptionId $env:SUBSCRIPTION_ID

$result = ./skills/azure/Invoke-AzureRestMethod.ps1 `
  -Uri "/subscriptions/$($ctx.SubscriptionId)/resourcegroups" `
  -ApiVersion '2021-04-01' `
  -AuthContext $ctx `
  -Paginate

$result.Value | Select-Object -First 10
  1. Run a PUT that returns async metadata (capture operation URLs)
$ctx = ./skills/azure/Connect-AzureApi.ps1 -AuthenticationType Certificate -Environment AzureCloud -TenantId $env:TENANT_ID -ClientId $env:CLIENT_ID -CertificatePath "/secure/certs/automation.pfx" -SubscriptionId $env:SUBSCRIPTION_ID

$payload = @{
  location = 'eastus'
  kind      = 'StorageV2'
  sku       = @{ name = 'Standard_LRS' }
}

$resp = ./skills/azure/Invoke-AzureRestMethod.ps1 `
  -Method PUT `
  -Uri "/subscriptions/$($ctx.SubscriptionId)/resourceGroups/$env:RG/providers/Microsoft.Storage/storageAccounts/$env:STORAGEACCOUNTNAME" `
  -ApiVersion '2023-05-01' `
  -Body $payload `
  -AuthContext $ctx

# Use one of these for polling, depending on what the service returns
$resp.OperationLocation
$resp.AzureAsyncOperation
$resp.Location
  1. Poll async status using the captured Azure-AsyncOperation URL
$ctx = ./skills/azure/Connect-AzureApi.ps1 -AuthenticationType Federated -Environment AzureCloud -TenantId $env:TENANT_ID -ClientId $env:CLIENT_ID -FederatedToken $env:AZURE_FEDERATED_TOKEN -SubscriptionId $env:SUBSCRIPTION_ID

$put = ./skills/azure/Invoke-AzureRestMethod.ps1 -Method PUT -Uri "/subscriptions/$($ctx.SubscriptionId)/resourceGroups/$env:RG/providers/Microsoft.Resources/deployments/$env:DEPLOYMENTNAME" -ApiVersion '2021-04-01' -Body @{ properties = @{ mode = 'Incremental'; templateLink = @{ uri = $env:TEMPLATE_URI } } } -AuthContext $ctx

$pollUri = $put.AzureAsyncOperation
while ($pollUri) {
  Start-Sleep -Seconds 5
  $status = ./skills/azure/Invoke-AzureRestMethod.ps1 -Method GET -Uri $pollUri -AuthContext $ctx
  $state = $status.Value.status
  if ($state -in @('Succeeded','Failed')) { break }
  $pollUri = $null  # if the server stopped returning an async URL, fall out
}
# 4) Use a config.yaml profile
$ctx = ./skills/azure/Connect-AzureApi.ps1 -Profile "prod" -ConfigPath "./config.yaml"
# 5) Use prefixed environment variables
$ctx = ./skills/azure/Connect-AzureApi.ps1 -Prefix "GOV" -Environment AzureUSGovernment

Prerequisites

  • Required modules: PowerShell 7.2+, MSAL.PS (recommended for certificate token acquisition, used by Common.psm1), Azure CLI az if MSAL.PS is unavailable for certificate flows.
  • Required roles: RBAC permissions on the target scope (subscription or resource group), for example Reader for read-only operations, Contributor or higher for PUT/PATCH/DELETE, and deployment permissions for ARM template deployments.

Related Docs

  • Auth Patterns
  • Token Chaining
  • Environment Endpoints

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.