使用现有令牌调用Microsoft.Azure.Fluent API

我正在使用microsoft.Azure…Fluent程序包对Azure进行REST API调用。目前,我正在使用以下内容初始化我的IAzure对象:

            var Credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(
                appID,secret,tenantID,AzureEnvironment.AzureGlobalCloud);

            Azure = microsoft.Azure.Management.Fluent.Azure
                .Configure()
                .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
                .Authenticate(Credentials)
                .WithSubscription(subscriptionID);

是否可以使用现有的“代表代币”令牌而不是使用客户端ID Client Secret初始化Azure对象?

gsyyyy 回答:使用现有令牌调用Microsoft.Azure.Fluent API

前端Web应用程序既可以获取图形令牌也可以获取ARM令牌,因此我可以使其工作如下:

            var customTokenProvider = new AzureCredentials(
                                    new TokenCredentials(**armToken**),new TokenCredentials(**graphToken**),tenantID,AzureEnvironment.AzureGlobalCloud);

            Azure = Microsoft.Azure.Management.Fluent.Azure
                .Configure()
                .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
                .Authenticate(customTokenProvider)
                .WithSubscription(subscriptionID);
本文链接:https://www.f2er.com/2548985.html

大家都在问