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.
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
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Templates.DeviceTemplates.Item.CreateDeviceFromTemplate;
var requestBody = new CreateDeviceFromTemplatePostRequestBody
{
ExternalDeviceId = "2fa9424e-7ab0-4a22-8c90-2a20d15d8183",
OperatingSystemVersion = "Ubuntu 18.04",
ExternalSourceName = "unknown",
AccountEnabled = false,
AlternativeNames = new List<string>
{
"/subscriptions/00001111-aaaa-2222-bbbb-3333cccc4444/resourcegroups/testrg/providers/microsoft.deviceregistry/assets/asset1",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Templates.DeviceTemplates["{deviceTemplate-id}"].CreateDeviceFromTemplate.PostAsync(requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphtemplates "github.com/microsoftgraph/msgraph-beta-sdk-go/templates"
//other-imports
)
requestBody := graphtemplates.NewCreateDeviceFromTemplatePostRequestBody()
externalDeviceId := "2fa9424e-7ab0-4a22-8c90-2a20d15d8183"
requestBody.SetExternalDeviceId(&externalDeviceId)
operatingSystemVersion := "Ubuntu 18.04"
requestBody.SetOperatingSystemVersion(&operatingSystemVersion)
externalSourceName := "unknown"
requestBody.SetExternalSourceName(&externalSourceName)
accountEnabled := false
requestBody.SetAccountEnabled(&accountEnabled)
alternativeNames := []string {
"/subscriptions/00001111-aaaa-2222-bbbb-3333cccc4444/resourcegroups/testrg/providers/microsoft.deviceregistry/assets/asset1",
}
requestBody.SetAlternativeNames(alternativeNames)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
createDeviceFromTemplate, err := graphClient.Templates().DeviceTemplates().ByDeviceTemplateId("deviceTemplate-id").CreateDeviceFromTemplate().Post(context.Background(), requestBody, nil)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.templates.devicetemplates.item.createdevicefromtemplate.CreateDeviceFromTemplatePostRequestBody createDeviceFromTemplatePostRequestBody = new com.microsoft.graph.beta.templates.devicetemplates.item.createdevicefromtemplate.CreateDeviceFromTemplatePostRequestBody();
createDeviceFromTemplatePostRequestBody.setExternalDeviceId("2fa9424e-7ab0-4a22-8c90-2a20d15d8183");
createDeviceFromTemplatePostRequestBody.setOperatingSystemVersion("Ubuntu 18.04");
createDeviceFromTemplatePostRequestBody.setExternalSourceName("unknown");
createDeviceFromTemplatePostRequestBody.setAccountEnabled(false);
LinkedList<String> alternativeNames = new LinkedList<String>();
alternativeNames.add("/subscriptions/00001111-aaaa-2222-bbbb-3333cccc4444/resourcegroups/testrg/providers/microsoft.deviceregistry/assets/asset1");
createDeviceFromTemplatePostRequestBody.setAlternativeNames(alternativeNames);
Device result = graphClient.templates().deviceTemplates().byDeviceTemplateId("{deviceTemplate-id}").createDeviceFromTemplate().post(createDeviceFromTemplatePostRequestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Templates\DeviceTemplates\Item\CreateDeviceFromTemplate\CreateDeviceFromTemplatePostRequestBody;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new CreateDeviceFromTemplatePostRequestBody();
$requestBody->setExternalDeviceId('2fa9424e-7ab0-4a22-8c90-2a20d15d8183');
$requestBody->setOperatingSystemVersion('Ubuntu 18.04');
$requestBody->setExternalSourceName('unknown');
$requestBody->setAccountEnabled(false);
$requestBody->setAlternativeNames(['/subscriptions/00001111-aaaa-2222-bbbb-3333cccc4444/resourcegroups/testrg/providers/microsoft.deviceregistry/assets/asset1', ]);
$result = $graphServiceClient->templates()->deviceTemplates()->byDeviceTemplateId('deviceTemplate-id')->createDeviceFromTemplate()->post($requestBody)->wait();
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.templates.devicetemplates.item.create_device_from_template.create_device_from_template_post_request_body import CreateDeviceFromTemplatePostRequestBody
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = CreateDeviceFromTemplatePostRequestBody(
external_device_id = "2fa9424e-7ab0-4a22-8c90-2a20d15d8183",
operating_system_version = "Ubuntu 18.04",
external_source_name = "unknown",
account_enabled = False,
alternative_names = [
"/subscriptions/00001111-aaaa-2222-bbbb-3333cccc4444/resourcegroups/testrg/providers/microsoft.deviceregistry/assets/asset1",
],
)
result = await graph_client.templates.device_templates.by_device_template_id('deviceTemplate-id').create_device_from_template.post(request_body)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.