Skip to content

Commit 586e2bd

Browse files
feat: Add re-authentication and retry logic for infrastructure provisioning failures
1 parent 983e5ca commit 586e2bd

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

.github/workflows/azure-dev.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,27 @@ jobs:
8888
azd env set principalId $principalId
8989
azd env set fabricWorkspaceMode skip
9090
- name: Provision Infrastructure
91+
id: provision-main
92+
continue-on-error: true
9193
run: azd provision --no-prompt
9294
env:
9395
AZD_INITIAL_ENVIRONMENT_CONFIG: ${{ secrets.AZD_INITIAL_ENVIRONMENT_CONFIG }}
96+
timeout-minutes: 60
97+
- name: Re-authenticate and Retry if Failed
98+
if: steps.provision-main.outcome == 'failure'
99+
run: |
100+
echo "::warning::First provision attempt failed. Re-authenticating and retrying..."
101+
102+
# Get fresh OIDC token and re-authenticate
103+
az logout
104+
az login --service-principal \
105+
--username ${{ vars.AZURE_CLIENT_ID }} \
106+
--tenant ${{ vars.AZURE_TENANT_ID }} \
107+
--allow-no-subscriptions \
108+
--federated-token $(curl -sS -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange" | jq -r .value)
109+
110+
az account set --subscription ${{ vars.AZURE_SUBSCRIPTION_ID }}
111+
112+
# Retry provision (will skip completed resources)
113+
azd provision --no-prompt
114+
timeout-minutes: 60

0 commit comments

Comments
 (0)