Hi everyone,
I'm encountering a puzzling issue in my Azure DevOps pipeline and would appreciate any insights or suggestions.
🔧 Setup Overview:
In the pipeline, I first run a custom .NET
extension that fetches an Azure access token using Service Principal credentials (AppId, AppKey, TenantId). Here's a simplified snippet:
var spnAccessTokenResponse = await retryPolicy.ExecuteAsync(() =>
azureTokenClient.TryFetchAzureAccessTokenUsingSPN(
credentialFetchTaskReqResponse.TenantId,
credentialFetchTaskReqResponse.AppId,
credentialFetchTaskReqResponse.AppKey)).ConfigureAwait(false);
After successfully retrieving the token, I proceed to run an Azure PowerShell task using a service connection configured with the same SPN credentials.
⚠️ Problem:
Even though the token fetch succeeds in the .NET task, the Azure PowerShell task intermittently retries due to what appears to be an AAD sync delay.
🧪 What I've Tried:
- Added retry logic with exponential backoff in the .NET code to improve resilience.PR - Aad Sync Issue - Adding retry to Get Credential... - DeploymentStd1B 4344234
- Validated that the service connection is correctly configured and matches the SPN used in the code.
- Confirmed that the token is valid and usable immediately after retrieval.
💡 Question:
Is there a known workaround or best practice to ensure that the Azure PowerShell task doesn’t hit these sync-related retries?
Any help or guidance would be greatly appreciated!.