You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/iot-dps/how-to-use-custom-allocation-policies.md
+11-12Lines changed: 11 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,6 @@ You perform the following steps in this article:
38
38
39
39
## Prerequisites
40
40
41
-
* Completion of the [Set up IoT Hub Device Provisioning Service with the Azure portal](./quick-setup-auto-provision.md) quickstart.
42
41
*[Visual Studio](https://visualstudio.microsoft.com/vs/) 2015 or later with the ['Desktop development with C++'](https://www.visualstudio.com/vs/support/selecting-workloads-visual-studio-2017/) workload enabled.
43
42
* Latest version of [Git](https://git-scm.com/download/) installed.
44
43
@@ -92,15 +91,15 @@ In this section, you use the Azure Cloud Shell to create a provisioning service
92
91
93
92
## Create the custom allocation function
94
93
95
-
In this section, you create an Azure function that implements your custom allocation policy. This function decides which IoT hub a device should be registered to based on whether its registration ID contains the string `-toasters-` or `-heatpumps-`. It also sets the initial state of the device twin based on whether the device is a toaster or a heat pump.
94
+
In this section, you create an Azure function that implements your custom allocation policy. This function decides which divisional IoT hub a device should be registered to based on whether its registration ID contains the string **-contoso-tstrsd-007** or **-contoso-hpsd-088**. It also sets the initial state of the device twin based on whether the device is a toaster or a heat pump.
96
95
97
96
1. Sign in to the [Azure portal](https://portal.azure.com). From your home page, select **+ Create a resource**.
98
97
99
98
2. In the *Search the Marketplace* search box, type "Function App". From the drop-down list select **Function App**, and then select **Create**.
100
99
101
100
3. On **Function App** create page, under the **Basics** tab, enter the following settings for your new function app and click **Review + create**:
102
101
103
-
**Resource Group**: Select **Use existing** and select the **contoso-us-resource-group** to keep all resources created in this article together.
102
+
**Resource Group**: Select the **contoso-us-resource-group** to keep all resources created in this article together.
104
103
105
104
**Function App name**: Enter a unique function app name. This example uses **contoso-function-app-1098**.
106
105
@@ -111,23 +110,23 @@ In this section, you create an Azure function that implements your custom alloca
111
110
**Region**: Select the same region as your resource group. This example uses **West US**.
112
111
113
112
> [!NOTE]
114
-
> By default, **Application Insights** is enabled. If you want to, you can disable it by selecting the **Monitoring** tab and selecting **No** for **Enable Application Insights**.
113
+
> By default, **Application Insights** is enabled. Application Insights is not necessary for this article, but it might help you understand If you want to, you can disable it by selecting the **Monitoring** tab and selecting **No** for **Enable Application Insights**.
115
114
116
115

117
116
118
117
4. On the **Summary** page, select **Create** to create the function app. Deployment may take several minutes. When it completes, select **Go to resource**.
119
118
120
-
5. On the left-hand pane of the **Overview** page, select **+** next to **Functions** to add a new function.
119
+
5. On the left pane of the function app **Overview** page, select **+** next to **Functions** to add a new function.
121
120
122
121

123
122
124
-
6. On **Azure Functions for .NET - getting started**, for the **CHOOSE A DEPLOYMENT ENVIRONMENT** step, select the **In-portal** tile, then select **Continue**.
123
+
6. On the **Azure Functions for .NET - getting started** page, for the **CHOOSE A DEPLOYMENT ENVIRONMENT** step, select the **In-portal** tile, then select **Continue**.
125
124
126
125

127
126
128
127
7. On the next page, for the **CREATE A FUNCTION** step, select the **Webhook + API** tile, then select **Create**. A function named **HttpTrigger1** is created, and the portal displays the contents of the **run.csx** code file.
129
128
130
-
8. Reference required Nuget packages. To create the initial device twin, the custom allocation function uses classes that are defined in two Nuget packages that must be loaded into the hosting environment. With Azure Functions, Nuget packages are referenced using a function.host file. In this step, you save and upload a function.host file.
129
+
8. Reference required Nuget packages. To create the initial device twin, the custom allocation function uses classes that are defined in two Nuget packages that must be loaded into the hosting environment. With Azure Functions, Nuget packages are referenced using a *function.host* file. In this step, you save and upload a *function.host* file.
131
130
132
131
1. Copy the following lines into your favorite editor and save the file on your computer as *function.host*.
133
132
@@ -147,11 +146,11 @@ In this section, you create an Azure function that implements your custom alloca
9. Replace the code for the **HttpTrigger1** function with the following code and click **Save**:
153
+
9. Replace the code for the **HttpTrigger1** function with the following code and select **Save**:
155
154
156
155
```csharp
157
156
#r "Newtonsoft.Json"
@@ -294,7 +293,7 @@ In this section, you create an Azure function that implements your custom alloca
294
293
295
294
In this section, you'll create a new enrollment group that uses the custom allocation policy. For simplicity, this article uses [Symmetric key attestation](concepts-symmetric-key-attestation.md) with the enrollment. For a more secure solution, consider using [X.509 certificate attestation](concepts-security.md#x509-certificates) with a chain of trust.
296
295
297
-
1. Still on the [Azure portal](https://portal.azure.com), open your Device Provisioning Service instance.
296
+
1. Still on the [Azure portal](https://portal.azure.com), open your provisioning service.
298
297
299
298
2. Select **Manage enrollments** on the left pane, and then click the **Add enrollment group** button at the top of the page.
300
299
@@ -504,7 +503,7 @@ This sample code simulates a device boot sequence that sends the provisioning re
504
503
The following output is an example of the simulated toaster device successfully booting up and connecting to the provisioning service instance to be assigned to the toasters IoT hub by the custom allocation policy:
505
504
506
505
```cmd
507
-
Provisioning API Version: 1.2.9
506
+
Provisioning API Version: 1.3.6
508
507
509
508
Registering Device
510
509
@@ -533,7 +532,7 @@ This sample code simulates a device boot sequence that sends the provisioning re
533
532
The following output is an example of the simulated heat pump device successfully booting up and connecting to the provisioning service instance to be assigned to the Contoso heat pumps IoT hub by the custom allocation policy:
0 commit comments