From f1f3b29e349a6e48fd06d22f62a4df648127b8c3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Jul 2026 12:00:53 +0000 Subject: [PATCH 1/6] Initial plan From c06cb077e553a4256870b7c6c02cb9edf9e54c85 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Jul 2026 12:31:32 +0000 Subject: [PATCH 2/6] feat: add shared Azure OIDC auth, Azure DevOps MCP, and improve Azure MCP docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #47768 - Azure and Azure DevOps MCP and CLI authentication not passed through agent. - shared/azure-auth.md: new shared component that re-authenticates Azure CLI inside the agent sandbox using OIDC federated identity. Fetches an OIDC token in pre-steps and runs 'az login --service-principal --federated-token' in pre-agent-steps, writing credentials to a writable AZURE_CONFIG_DIR (/tmp/gh-aw/agent/.azure). This crosses the runner→agent process boundary that caused PermissionError on /home/runner/.azure. - shared/mcp/azure-devops.md: new shared component for the Azure DevOps HTTP MCP server at https://mcp.dev.azure.com/. Authenticates via ADO_MCP_AUTH_TOKEN bearer header. Adds network allow-list for *.dev.azure.com, *.visualstudio.com, and *.microsoftonline.com. - shared/mcp/azure.md: adds network allow-list entries for Azure service domains, and adds a documentation section showing the OIDC/command-based authentication alternative using shared/azure-auth.md + @azure/mcp npm package. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/workflows/shared/azure-auth.md | 162 +++++++++++++++++++ .github/workflows/shared/mcp/azure-devops.md | 80 +++++++++ .github/workflows/shared/mcp/azure.md | 67 ++++++-- 3 files changed, 295 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/shared/azure-auth.md create mode 100644 .github/workflows/shared/mcp/azure-devops.md diff --git a/.github/workflows/shared/azure-auth.md b/.github/workflows/shared/azure-auth.md new file mode 100644 index 00000000000..e8c88a727b7 --- /dev/null +++ b/.github/workflows/shared/azure-auth.md @@ -0,0 +1,162 @@ +--- +description: Azure CLI OIDC re-authentication for agentic workflows. +import-schema: + azure-client-id: + type: string + required: true + description: Azure App (client) ID for OIDC authentication + azure-tenant-id: + type: string + required: true + description: Azure tenant ID + +permissions: + id-token: write + +env: + AZURE_CONFIG_DIR: /tmp/gh-aw/agent/.azure + +network: + allowed: + - login.microsoftonline.com + - management.azure.com + +pre-steps: + - name: Fetch Azure OIDC token + id: azure-oidc + run: | + OIDC_TOKEN=$(curl -sS \ + -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \ + "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=api://AzureADTokenExchange" \ + | jq -r '.value') + if [ -z "$OIDC_TOKEN" ] || [ "$OIDC_TOKEN" = "null" ]; then + echo "::error::Failed to obtain Azure OIDC token — ensure id-token: write permission is granted" + exit 1 + fi + TOKEN_FILE="/tmp/gh-aw/azure/oidc-token.txt" + mkdir -p "$(dirname "$TOKEN_FILE")" + printf '%s' "$OIDC_TOKEN" > "$TOKEN_FILE" + chmod 600 "$TOKEN_FILE" + echo "GH_AW_AZURE_OIDC_TOKEN_FILE=$TOKEN_FILE" >> "$GITHUB_ENV" + +pre-agent-steps: + - name: Re-authenticate Azure CLI with OIDC + env: + GH_AW_AZURE_CLIENT_ID: ${{ github.aw.import-inputs.azure-client-id }} + GH_AW_AZURE_TENANT_ID: ${{ github.aw.import-inputs.azure-tenant-id }} + run: | + if [ -z "$GH_AW_AZURE_OIDC_TOKEN_FILE" ] || [ ! -f "$GH_AW_AZURE_OIDC_TOKEN_FILE" ]; then + echo "::error::Azure OIDC token file not found — the Fetch Azure OIDC token step may have failed" + exit 1 + fi + mkdir -p "$AZURE_CONFIG_DIR" + chmod 700 "$AZURE_CONFIG_DIR" + OIDC_TOKEN=$(cat "$GH_AW_AZURE_OIDC_TOKEN_FILE") + az login --service-principal \ + --username "$GH_AW_AZURE_CLIENT_ID" \ + --tenant "$GH_AW_AZURE_TENANT_ID" \ + --federated-token "$OIDC_TOKEN" \ + --output none + rm -f "$GH_AW_AZURE_OIDC_TOKEN_FILE" + az account show --output table +--- + + diff --git a/.github/workflows/shared/mcp/azure-devops.md b/.github/workflows/shared/mcp/azure-devops.md new file mode 100644 index 00000000000..ae1bcf98966 --- /dev/null +++ b/.github/workflows/shared/mcp/azure-devops.md @@ -0,0 +1,80 @@ +--- +description: Azure DevOps MCP server for agentic workflows. +import-schema: + organization: + type: string + required: true + description: Azure DevOps organization name (the subdomain in https://dev.azure.com/) + +network: + allowed: + - "*.dev.azure.com" + - "*.visualstudio.com" + - "*.microsoftonline.com" + +mcp-servers: + azure-devops: + url: "https://mcp.dev.azure.com/${{ github.aw.import-inputs.organization }}" + headers: + Authorization: "${{ secrets.ADO_MCP_AUTH_TOKEN }}" + allowed: + - "*" +--- + + diff --git a/.github/workflows/shared/mcp/azure.md b/.github/workflows/shared/mcp/azure.md index d6ae938c0c9..8b7d1983aa1 100644 --- a/.github/workflows/shared/mcp/azure.md +++ b/.github/workflows/shared/mcp/azure.md @@ -20,6 +20,12 @@ mcp-servers: - "group_get" - "resource_list" - "resource_get" + +network: + allowed: + - login.microsoftonline.com + - management.azure.com + - "*.azure.com" ---