问题描述
使用设备供应服务在azure IoT中心删除已注册的设备所需的URL格式是什么...
我读了这篇文章,但是却抛出了404
在请求标头中,我添加了If-Match标签,但我是否需要添加带有SaS令牌的授权标签,如果需要,SaS令牌将是我用于使用Device Provisioning Service注册设备的令牌
解决方法
如果我需要SaS令牌,它将是我用于注册的令牌 设备使用设备预配服务
要生成access_token
(将在请求的Authorization
标头中使用),需要遵循一些步骤。
先决条件:
- 安装Python 2.7+
- 安装Azure CLI 2.0+
- 登录到CLI
以下是步骤:
使用Azure CLI登录
az login
设置活动订阅
az account set --subscription "your subscription name or id"
创建服务主体
az ad sp create-for-rbac -n "your service principal name. Can be like 'jongpostman7'"
将此输出复制到临时位置,一分钟之内将需要这些值。
现在应邮递员的要求。您需要先致电AAD Token request
,其回复将为您提供access_token
。您可以在DPS删除设备请求中使用此访问令牌。 AAD请求将如下所示:-
POST https://login.microsoftonline.com/{{tenantId}}/oauth2/token
请参阅下面的图像以获取请求正文。
grant_type
是client_credentials
client_id
是以上命令输出中收到的appId
client_secret
是以上命令输出中收到的password
tenant_id
是以上命令输出中收到的tenant
resource
是https://management.azure.com/
现在,您拥有可以在DPS删除设备REST API中使用的access_token
。
Authorization标头如下:
Authorization
:Bearer <access_token_received_above>
参考链接here。