是否可以为守护程序应用配置 Azure 数字孪生 API 访问? [英] Is it possible to configure Azure Digital Twins API access for a Daemon App?

查看:16
本文介绍了是否可以为守护程序应用配置 Azure 数字孪生 API 访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了自动维护 Azure 数字孪生实例,我们需要服务到服务 API 访问,以便我们可以使用 Azure 中间层选项作为守护程序应用程序(例如逻辑应用程序或函数)运行.

To automate maintenance of an Azure Digital Twins instance, we require service-to-service API access so that we can use Azure middle-tier options to run as daemon apps (e.g. Logic App or Function).

但是,在 Azure Active Directory 中注册应用程序时,Azure 数字孪生预览版"API(资源 id:0b07f429-9f4b-4714-9392-cc5e8e80c8b0)不支持应用程序权限(仅限委派权限).但是,相关的 Microsoft Graph API(资源 id:00000003-0000-0000-c000-000000000000)支持这两种权限类型.

However, the Azure Digitial Twins 'preview' API (resource id: 0b07f429-9f4b-4714-9392-cc5e8e80c8b0) does not support Application Permissions when registering the application in Azure Active Directory (only Delegated Permissions). However, the related Microsoft Graph API (resource id: 00000003-0000-0000-c000-000000000000) supports both permission types.

目前是否有任何方法无需登录 AAD 帐户(即使用client_credentials"授权类型)即可对 Azure 数字孪生 API 的访问进行身份验证?

Is there any way currently to authenticate for access to the Azure Digital Twins API without the need for a signed-in AAD account (i.e. using 'client_credentials' grant type)?

推荐答案

  1. 首先,您需要将在 Azure AD 中注册的控制台应用程序的新角色 (RABC) 添加到 azure digital twins 实例中.

  1. First you need to add new role (RABC) for console application which is registered in the Azure AD into azure digital twins instance.

为控制台应用创建客户端密码.

Create client secret for console app.

 private static DigitalTwinsClient GetDigitalTwinsClient(string tenantId, string clientId, string clientSecret, string adtEndpoint)
 {
     Environment.SetEnvironmentVariable("AZURE_CLIENT_SECRET", clientSecret);
     Environment.SetEnvironmentVariable("AZURE_CLIENT_ID", clientId);
     Environment.SetEnvironmentVariable("AZURE_TENANT_ID", tenantId);

     var tokenCredential = new DefaultAzureCredential();

     var client = new DigitalTwinsClient(
         new Uri(adtEndpoint),
         tokenCredential, new DigitalTwinsClientOptions
         { Transport = new HttpClientTransport(httpClient) });

     return client;
 }

这篇关于是否可以为守护程序应用配置 Azure 数字孪生 API 访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆