Description
Description
Can you please help us with following issue:
We've encountered an issue potentially linked to the Az.Storage cmdlet command. A customer reported this problem within a long-running pipeline designed to store data in an Azure Storage Account, utilizing the New-AzStorageContext and Set-AzStorageBlobContent cmdlets. This process authenticates to Azure using a federated token.
According to the stack trace, an error occurs roughly 55 minutes after the script starts, coinciding with the access token's expiration. The NewAzureStorageContext function attempts to renew the token but fails, generating the following error: "Client assertion is not within its valid time range. Current time: 2024-02-28T09:53:28.3990795Z, assertion valid from: 2024-02-28T08:57:57.0000000Z, expiry time of assertion: 2024-02-28T09:07:57.0000000Z." The token, which has a 10-minute lifespan, is identified as a federated token. We suspect that New-AzStorageContext attempts to use this short-lived federated token to refresh the access token, leading to failure upon the federated token's expiration.
Is it standard practice for New-AzStorageContext to employ a federated token for refreshing the access token?
If this behavior is not anticipated, could you provide any insights into the potential causes of this issue?
Issue script & Debug output
An error has occurred that was not properly handled. Additional information is shown below. The PowerShell process will exit.
2024-02-28T09:53:28.4544101Z Unhandled exception. MSAL.NetCore.4.49.1.0.MsalServiceException:
2024-02-28T09:53:28.4544494Z ErrorCode: invalid_client
2024-02-28T09:53:28.4546639Z Microsoft.Identity.Client.MsalServiceException: A configuration issue is preventing authentication - check the error message from the server for details. You can modify the configuration in the application registration portal. See [https://aka.ms/msal-net-invalid-client](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2Fmsal-net-invalid-client&data=05%7C02%7Cigortsoi%40microsoft.com%7C6b6de2a5de574995a9cd08dc39062b92%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638447945881838012%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=XJvFG8RJxWz2v8E3mqSHLj8LNTOAAHzqZ1pfrNiA8aE%3D&reserved=0) for details. Original exception: AADSTS700024: Client assertion is not within its valid time range. Current time: 2024-02-28T09:53:28.3990795Z, assertion valid from 2024-02-28T08:57:57.0000000Z, expiry time of assertion 2024-02-28T09:07:57.0000000Z. Review the documentation at [https://docs.microsoft.com/azure/active-directory/develop/active-directory-certificate-credentials](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Factive-directory%2Fdevelop%2Factive-directory-certificate-credentials&data=05%7C02%7Cigortsoi%40microsoft.com%7C6b6de2a5de574995a9cd08dc39062b92%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638447945881849600%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=t3F%2B7IHZwwuPtFlTVj5Mz8KCCMOkBF62qwYflpKr2Io%3D&reserved=0) . Trace ID: f138e6d0-dc83-4626-8cd7-d972a7500e00 Correlation ID: 61054eac-dd48-453b-ad65-99387a33af78 Timestamp: 2024-02-28 09:53:28Z
2024-02-28T09:53:28.4548292Z at Microsoft.Identity.Client.Internal.Requests.RequestBase.HandleTokenRefreshErrorAsync(MsalServiceException e, MsalAccessTokenCacheItem cachedAccessTokenItem)
2024-02-28T09:53:28.4548758Z at Microsoft.Identity.Client.Internal.Requests.ClientCredentialRequest.ExecuteAsync(CancellationToken cancellationToken)
2024-02-28T09:53:28.4549154Z at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken cancellationToken)
2024-02-28T09:53:28.4549856Z at Microsoft.Identity.Client.ApiConfig.Executors.ConfidentialClientExecutor.ExecuteAsync(AcquireTokenCommonParameters commonParameters, AcquireTokenForClientParameters clientParameters, CancellationToken cancellationToken)
2024-02-28T09:53:28.4550676Z at Microsoft.Azure.PowerShell.Authenticators.Identity.MsalConfidentialClient.AcquireTokenForClientCoreAsync(String[] scopes, String tenantId, Boolean async, CancellationToken cancellationToken)
2024-02-28T09:53:28.4551277Z at Microsoft.Azure.PowerShell.Authenticators.Identity.MsalConfidentialClient.AcquireTokenForClientAsync(String[] scopes, String tenantId, Boolean async, CancellationToken cancellationToken)
2024-02-28T09:53:28.4551765Z at Microsoft.Azure.PowerShell.Authenticators.Identity.TaskExtensions.EnsureCompleted[T](ValueTask`1 task)
2024-02-28T09:53:28.4552236Z at Microsoft.Azure.PowerShell.Authenticators.Identity.ClientAssertionCredential.GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
2024-02-28T09:53:28.4552668Z at Microsoft.Azure.PowerShell.Authenticators.MsalAccessToken.Renew()
2024-02-28T09:53:28.4553030Z at Microsoft.Azure.PowerShell.Authenticators.MsalAccessToken.AuthorizeRequest(Action`2 authTokenSetter)
2024-02-28T09:53:28.4553465Z at Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet.NewAzureStorageContext.GetTokenStrFromAccessToken(IAccessToken accessToken)
2024-02-28T09:53:28.4553940Z at Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet.NewAzureStorageContext.<>c__DisplayClass103_0.<<GetTokenRenewer>b__0>d.MoveNext()
2024-02-28T09:53:28.4554392Z --- End of stack trace from previous location ---
2024-02-28T09:53:28.4554698Z at Microsoft.Azure.Storage.Auth.TokenCredential.RenewTokenAsync(Object state)
2024-02-28T09:53:28.4555023Z at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
2024-02-28T09:53:28.4555326Z at System.Threading.QueueUserWorkItemCallback.Execute()
2024-02-28T09:53:28.4555611Z at System.Threading.ThreadPoolWorkQueue.Dispatch()
2024-02-28T09:53:28.4555914Z at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
2024-02-28T09:53:28.4556170Z StatusCode: 401
2024-02-28T09:53:28.4558040Z ResponseBody: {"error":"invalid_client","error_description":"AADSTS700024: Client assertion is not within its valid time range. Current time: 2024-02-28T09:53:28.3990795Z, assertion valid from 2024-02-28T08:57:57.0000000Z, expiry time of assertion 2024-02-28T09:07:57.0000000Z. Review the documentation at [https://docs.microsoft.com/azure/active-directory/develop/active-directory-certificate-credentials](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Factive-directory%2Fdevelop%2Factive-directory-certificate-credentials&data=05%7C02%7Cigortsoi%40microsoft.com%7C6b6de2a5de574995a9cd08dc39062b92%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638447945881855995%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=9My228m88stlW24HRySuZn3Cb0a2X%2FnSl4mAWKW6QEg%3D&reserved=0) . Trace ID: f138e6d0-dc83-4626-8cd7-d972a7500e00 Correlation ID: 61054eac-dd48-453b-ad65-99387a33af78 Timestamp: 2024-02-28 09:53:28Z","error_codes":[700024],"timestamp":"2024-02-28 09:53:28Z","trace_id":"f138e6d0-dc83-4626-8cd7-d972a7500e00","correlation_id":"61054eac-dd48-453b-ad65-99387a33af78","error_uri":[https://login.microsoftonline.com/error?code=700024](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flogin.microsoftonline.com%2Ferror%3Fcode%3D700024&data=05%7C02%7Cigortsoi%40microsoft.com%7C6b6de2a5de574995a9cd08dc39062b92%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638447945881861947%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=jw9qfbZzjMnWy001JPqaTTpl4WiSvrWy3I%2Fsv%2FuSHRA%3D&reserved=0)}
Environment data
N/A
Module versions
N/A
Error output
No response