我如何创建一个Azure凭据来访问WebItemManagementClient?

我如何创建一个Azure凭据来访问WebItemManagementClient?,azure,azure-web-app-service,credentials,azure-active-directory,azure-sdk-.net,Azure,Azure Web App Service,Credentials,Azure Active Directory,Azure Sdk .net,我想使用Azure SDK中的WebItemManagementClient,但我遇到了第一个障碍——创建客户端。我已经创建了一个Active Directory应用程序,按照和提供的说明创建了一个TokenCredential,我成功地使用它使用SQLManagementClient创建了SQL数据库 ClientCredential cc = new ClientCredential("{myApplicationId}", "{myAzurePassword}"); var context

我想使用Azure SDK中的WebItemManagementClient,但我遇到了第一个障碍——创建客户端。我已经创建了一个Active Directory应用程序,按照和提供的说明创建了一个TokenCredential,我成功地使用它使用SQLManagementClient创建了SQL数据库

ClientCredential cc = new ClientCredential("{myApplicationId}", "{myAzurePassword}");
var context = new AuthenticationContext("https://login.windows.net/{myTennantId}");
var result = context.AcquireToken("https://management.azure.com/", cc);
if (result == null)
    throw new InvalidOperationException("Failed to obtain the JWT token");
TokenCloudCredentials CloudCred = new TokenCloudCredentials(subscriptionId, result.AccessToken);
var sqlClient = new SqlManagementClient(CloudCred);
...
// and this can be used to create databases in resource groups
WebItemManagementClient似乎需要一组不同的参数。首先,它需要一个ServiceClientCredential,然后是一些DelegatingHandler。我在哪里可以获得ServiceClientCredential?什么是授权处理者。我找了一个博客,上面有这样的例子,但没有成功。我非常感谢任何指点。
感谢继续我的搜索,我发现并回答了一个类似的问题,但这次是访问ComputeManagementClient。在那里测试了解决方案后,我意识到我已经非常接近了。我只需要使用result.AccessToken而不是SubscriptionID创建凭证,如下所示

ClientCredential cc = new ClientCredential("{myApplicationId}", "{myAzurePassword}");
var context = new AuthenticationContext("https://login.windows.net/{myTennantId}");
var result = context.AcquireToken("https://management.azure.com/", cc);
if (result == null)
    throw new InvalidOperationException("Failed to obtain the JWT token");
TokenCredentials Cred = new TokenCredentials(result.AccessToken);
var sqlClient = new SqlManagementClient(CloudCred);
...
// and this can be used to create databases in resource groups

我要感谢Noah Stahl,他在那里提供了答案

当我按照您的建议操作时,我在尝试使用WebItemanagmentClient(创建它时)时得到了PlatformNotSupportedException。我能找到的每一个样品都需要一份证书,但为什么需要这样做却毫无意义。思想?