| title | deviceTemplate: createDeviceFromTemplate |
|---|---|
| description | Create a new device from a device template. |
| author | atastrophic |
| ms.date | 12/31/2024 |
| ms.localizationpriority | medium |
| ms.subservice | entra-id |
| doc_type | apiPageType |
Namespace: microsoft.graph
[!INCLUDE beta-disclaimer]
Create a new device from a deviceTemplate.
[!INCLUDE national-cloud-support]
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.
[!INCLUDE permissions-table]
[!INCLUDE rbac-devicestemplate-apis]
Note: Users must be owner of the object.
POST /directory/templates/deviceTemplates/{deviceTemplateId}/createDeviceFromTemplate| Name | Description |
|---|---|
| Authorization | Bearer {token}. Required. Learn more about authentication and authorization. |
| Content-Type | application/json. Required. |
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. |
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.
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"
]
}[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
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..."
}
]
}