Skip to content

Commit 0064785

Browse files
committed
Refactor: Update Azure CLI login method to use federated identity instead of service principal
1 parent e5a18ee commit 0064785

1 file changed

Lines changed: 11 additions & 21 deletions

File tree

‎.github/workflows/copilot-setup-steps.yml‎

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ permissions:
1010
contents: read
1111
issues: write
1212

13-
env:
14-
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
15-
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
16-
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
17-
ARM_USE_OIDC: true
18-
1913
jobs:
2014
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
2115
copilot-setup-steps:
@@ -35,23 +29,19 @@ jobs:
3529
- name: Checkout code
3630
uses: actions/checkout@v5
3731

38-
# Azure CLI is pre-installed on ubuntu-latest runners
39-
# Login using service principal with client secret instead of federated identity
40-
# This persists for the entire runner session, including when Copilot runs
41-
- name: Azure CLI Login with Service Principal
42-
env:
43-
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
44-
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
45-
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
46-
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
47-
run: |
48-
az login --service-principal \
49-
--username "$ARM_CLIENT_ID" \
50-
--password "$ARM_CLIENT_SECRET" \
51-
--tenant "$ARM_TENANT_ID"
52-
az account set --subscription "$ARM_SUBSCRIPTION_ID"
32+
# Get OIDC token and login to Azure using federated identity
33+
# This happens during setup when we have id-token permission
34+
- name: Azure CLI Login with Federated Identity
35+
uses: azure/login@v2
36+
with:
37+
client-id: ${{ secrets.ARM_CLIENT_ID }}
38+
tenant-id: ${{ secrets.ARM_TENANT_ID }}
39+
subscription-id: ${{ secrets.ARM_SUBSCRIPTION_ID }}
5340

5441
- name: Validate Azure Auth Works
5542
run: |
5643
az account show
5744
az group list --output table
45+
echo "Azure CLI authentication successful and persisted for Copilot"
46+
az account show
47+
az group list --output table

0 commit comments

Comments
 (0)