편집

다음을 통해 공유


deviceTemplate: createDeviceFromTemplate

Namespace: microsoft.graph

Important

APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.

Create a new device from a deviceTemplate.

This API is available in the following national cloud deployments.

Global service US Government L4 US Government L5 (DOD) China operated by 21Vianet

Permissions

Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.

Permission type Least privileged permissions Higher privileged permissions
Delegated (work or school account) Device.CreateFromOwnedTemplate Not available.
Delegated (personal Microsoft account) Not supported. Not supported.
Application Not supported. Not supported.

Important

In delegated scenarios with work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with a supported role permission. The following least privileged roles are supported for this operation:

  • Cloud Device Administrator
  • IoT Device Administrator
  • Users - owners of the device template object

Note: Users must be owner of the object.

HTTP request

POST /directory/templates/deviceTemplates/{deviceTemplateId}/createDeviceFromTemplate

Request headers

Name Description
Authorization Bearer {token}. Required. Learn more about authentication and authorization.
Content-Type application/json. Required.

Request body

In the request body, supply a JSON representation of the parameters.

The following table lists the parameters that you can use when you call this action.

Parameter Type Description
accountEnabled Boolean true if the account is enabled; otherwise, false. The default value is true. A disabled device can't authenticate with Microsoft Entra ID. Optional.
alternativeNames String collection A collection of ARM resource IDs associated with the device, if any. Optional.
externalDeviceId String ID of the device in IoT registry. Must be unique within a tenant. Required.
externalSourceName String Identifies the source name of the device. Optional.
keyCredential keyCredential The key credential when you use self-signed certificates. Optional.
operatingSystemVersion String The operating system version of the device specified. Optional.

Response

If successful, this action returns a 200 OK response code and a device object in the response body.

For more information, see Microsoft Graph error responses and resource types.

Examples

Request

The following example shows a request.

POST https://graph.microsoft.com/beta/templates/deviceTemplates/2d62b12a-0163-457d-9796-9602e9807e1/createDeviceFromTemplate
Content-Type: application/json

{
  "externalDeviceId": "2fa9424e-7ab0-4a22-8c90-2a20d15d8183",
  "operatingSystemVersion": "Ubuntu 18.04",
  "externalSourceName": "unknown",
  "accountEnabled": false,
  "alternativeNames": [
    "/subscriptions/00001111-aaaa-2222-bbbb-3333cccc4444/resourcegroups/testrg/providers/microsoft.deviceregistry/assets/asset1"
  ]
}

Response

The following example shows the response.

Note: The response object shown here might be shortened for readability.

HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": "06d59f74-dbf3-432a-9971-c5f60374e4f0",
  "accountEnabled": false,
  "alternativeNames": [
    "/subscriptions/00001111-aaaa-2222-bbbb-3333cccc4444/resourcegroups/testrg/providers/microsoft.deviceregistry/assets/asset1"
  ],
  "deviceId": "c6ca2657-8685-4398-9edc-a6a603f177b3",
  "displayName": "2fa9424e-7ab0-4a22-8c90-2a20d15d8183",
  "externalSourceName": "unknown",
  "manufacturer": "IoT Device Template Manufacturer",
  "model": "IoT Device Template Model",
  "operatingSystem": "WindowsIoT",
  "operatingSystemVersion": "Ubuntu 18.04",
  "physicalIds": [
    "[EXTID]:2fa9424e-7ab0-4a22-8c90-2a20d15d8183"
  ],
  "profileType": "IoT",
  "sourceType": "External",
  "alternativeSecurityIds": [
    {
      "type": 2,
      "identityProvider": null,
      "key": "WAA1ADAAOQA6ADwAVQB..."
    }
  ]
}