azure - 如何使用 azure 广告应用程序访问 token 访问 azure 调度程序

标签 azure

我遵循以下指南: https://azure.microsoft.com/en-gb/documentation/articles/virtual-machines-arm-deployment/

设置 azure 广告应用程序。

但它似乎不适用于 azure 调度程序。 var cred = new TokenCloudCredentials(_options.SubscriptionId, _options.Token);

using (var schedulerServiceClient = new Microsoft.WindowsAzure.Management.Scheduler.CloudServiceManagementClient(cred))
{
    var services = await schedulerServiceClient.CloudServices.ListAsync(token);
}

错误和输出如下所示。我的问题是, azure 广告应用程序不适用于所有 azure 服务吗?

我尝试了一些方法,例如代表我自己使用 azure token 而不是 azure 应用程序,然后它工作得很好。

Test Name:  TestMethod1
Test Outcome:   Failed
Result Message: 
Test method Ascend.Scheduler.Tests.UnitTest1.TestMethod1 threw exception: 
Hyak.Common.CloudException: ForbiddenError: The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription.
Result StandardOutput:  
Debug Trace:
te.processhost.managed.exe Information: 0 : 12/6/2015 9:36:25 PM:  - AuthenticationContext: ADAL .NET with assembly version '2.19.0.0', file version '2.19.20802.0213' and informational version 'f719a3fb5ab2559980bb7e75ee78bc15068282fa' is running...
te.processhost.managed.exe Information: 0 : 12/6/2015 9:36:25 PM: e9d31ff5-f1ed-4bf6-b1d7-a180841409d6 - AcquireTokenHandlerBase: === Token Acquisition started:
    Authority: https://login.windows.net/ascend.xyz/
    Resource: https://management.core.windows.net/
    ClientId: 5519b0a9-aeef-4ff8-b41b-2598a6888687
    CacheType: Microsoft.IdentityModel.Clients.ActiveDirectory.TokenCache (0 items)
    Authentication Target: Client

te.processhost.managed.exe Information: 0 : 12/6/2015 9:36:25 PM: e9d31ff5-f1ed-4bf6-b1d7-a180841409d6 - TokenCache: Looking up cache for a token...
te.processhost.managed.exe Information: 0 : 12/6/2015 9:36:25 PM: e9d31ff5-f1ed-4bf6-b1d7-a180841409d6 - TokenCache: No matching token was found in the cache
te.processhost.managed.exe Information: 0 : 12/6/2015 9:36:26 PM: e9d31ff5-f1ed-4bf6-b1d7-a180841409d6 - TokenCache: Storing token in the cache...
te.processhost.managed.exe Information: 0 : 12/6/2015 9:36:26 PM: e9d31ff5-f1ed-4bf6-b1d7-a180841409d6 - TokenCache: An item was stored in the cache
te.processhost.managed.exe Information: 0 : 12/6/2015 9:36:26 PM: e9d31ff5-f1ed-4bf6-b1d7-a180841409d6 - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned:
    Access Token Hash: JMsx9YOCod0W2iHyyRwr6n3FBo8qp/X/iGNGmZxlvbw=
    Refresh Token Hash: [No Refresh Token]
    Expiration Time: 12/6/2015 10:36:25 PM +00:00
    User Hash: null

最佳答案

Azure Scheduler 支持服务管理和资源管理终结点。服务管理端点 ( https://management.core.windows.net/ ) 使用证书,资源管理 ( https://management.azure.com/ ) 端点使用 OAuth。 您可以使用 Azure 资源管理器调度程序 SDK ( https://www.nuget.org/packages/Microsoft.Azure.Management.Scheduler ),该 SDK 使用 OAuth 进行身份验证来管理您的调度程序作业。

问候, 林嘉颖

关于azure - 如何使用 azure 广告应用程序访问 token 访问 azure 调度程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34123149/

相关文章:

c# - 使用 Entity Framework 6 中的环境变量在暂存/生产数据库之间切换

azure - 缺少 Azure 服务总线命名空间的管理 UI

Azure SQL Server 防火墙 IP 地址范围

node.js - 我可以在 Microsoft Azure 上的 Node.JS 中使用 native 'fs' 文件系统吗?

azure - 如何以非 root 用户身份在自托管构建代理上执行管道

Azure 应用程序网关锁定了应用程序服务的路由

azure - 删除无法使用 CI CD 管道工作的数据工厂组件

node.js - Azure DevOps 管道打开的文件太多

c# - 使用 Azure DocumentDB 和 MVC5 处理动态数据

具有动态 IP 的 Azure