private static ManagedIdentitySource SelectManagedIdentitySource(ManagedIdentityClientOptions options)
 {
     return
         (ServiceFabricManagedIdentitySource.TryCreate(options) ??
          AppServiceV2019ManagedIdentitySource.TryCreate(options) ??
          AppServiceV2017ManagedIdentitySource.TryCreate(options) ??
          CloudShellManagedIdentitySource.TryCreate(options) ??
          AzureArcManagedIdentitySource.TryCreate(options) ??
          TokenExchangeManagedIdentitySource.TryCreate(options) ??
          new ImdsManagedIdentitySource(options));
 }
        private protected virtual async ValueTask <IManagedIdentitySource> GetManagedIdentitySourceAsync(bool async, CancellationToken cancellationToken)
        {
            using var asyncLock = await _identitySourceAsyncLock.GetLockOrValueAsync(async, cancellationToken).ConfigureAwait(false);

            if (asyncLock.HasValue)
            {
                return(asyncLock.Value);
            }

            IManagedIdentitySource identitySource = AppServiceV2019ManagedIdentitySource.TryCreate(_pipeline.HttpPipeline, ClientId) ??
                                                    AppServiceV2017ManagedIdentitySource.TryCreate(_pipeline.HttpPipeline, ClientId) ??
                                                    CloudShellManagedIdentitySource.TryCreate(_pipeline.HttpPipeline, ClientId) ??
                                                    await ImdsManagedIdentitySource.TryCreateAsync(_pipeline.HttpPipeline, ClientId, async, cancellationToken).ConfigureAwait(false);

            asyncLock.SetValue(identitySource);
            return(identitySource);
        }