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

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

            ManagedIdentitySource identitySource = AppServiceV2017ManagedIdentitySource.TryCreate(_options) ??
                                                   CloudShellManagedIdentitySource.TryCreate(_options) ??
                                                   AzureArcManagedIdentitySource.TryCreate(_options) ??
                                                   ServiceFabricManagedIdentitySource.TryCreate(_options) ??
                                                   await ImdsManagedIdentitySource.TryCreateAsync(_options, async, cancellationToken).ConfigureAwait(false);

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