Esempio n. 1
0
        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 = 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);
        }
        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);
        }