使用Azure设备配置服务的其余API删除设备? [英] Delete Device using rest API of Azure device provisioning service?

查看:55
本文介绍了使用Azure设备配置服务的其余API删除设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用设备供应服务在azure IoT中心删除已注册的设备所需的URL格式是什么...

我读了这篇文章,但是却抛出了404

将此输出复制到临时位置,一分钟之内将需要这些值.

现在应邮递员的要求.您需要先调用 AAD令牌请求,其响应将为您提供 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 资源 https://management.azure.com/

以上请求的响应如下:-

现在,您有了可以在DPS删除设备REST API中使用的 access_token .Authorization标头如下:

授权:承载者< access_token_received_above>

参考链接此处.

What is the format of the url needed to delete an already registered device in azure IoT hub using device provisioning service...

I read this article but it throws me 404

https://docs.microsoft.com/en-us/rest/api/iot-dps/deletedeviceregistrationstate/deletedeviceregistrationstate

In the request header I added If-Match tag but do I need to add Authorization tag with the SaS token and if I need the SaS token will be the one which I used for registering device using Device Provisioning Service

解决方案

if I need the SaS token will be the one which I used for registering device using Device Provisioning Service

There are some steps that you need to follow to generate the access_token that will be used in the Authorization header of the request.

Prerequisites:

Below are the steps:

Login with Azure CLI

az login

Set Active Subscription

az account set --subscription "your subscription name or id"

Create Service Principal

az ad sp create-for-rbac -n "your service principal name. Can be like 'jongpostman7'"

The output of above command will be something like below image.

Copy this output to a temp location, you will need the values in a minute.

Coming to the Postman request now. You need to first call the AAD Token request whose response will provide you with the access_token. This access token you can use in the DPS delete device request. The AAD request will be like below:-

POST https://login.microsoftonline.com/{{tenantId}}/oauth2/token Refer image below for the request body.

grant_type is client_credentials client_id is the appId received in above command output client_secret is the password received in above command output tenant_id is the tenant received in above command output resource is https://management.azure.com/

The response of above request will be like below:-

Now, you have the access_token that can be used in the DPS delete device REST API. The Authorization header be like below:

Authorization: Bearer <access_token_received_above>

Reference link here.

这篇关于使用Azure设备配置服务的其余API删除设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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