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/tutorial-custom-allocation-policies.md
+29-33Lines changed: 29 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,30 +51,26 @@ In this section, you use the Azure Cloud Shell to create a provisioning service
51
51
52
52
The DPS and IoT Hub names must be globally unique. Replace the `SUFFIX` placeholder with your own value.
53
53
54
-
Also, the Azure Function code you create later in this tutorial looks for IoT hubs that have either `-toasters-` or `-heatpups-` in their names. If you change the suggested values, make sure to use names that contain the required substrings.
55
-
56
-
### [Bash](#tab/bash)
54
+
Also, the Azure Function code you create later in this tutorial looks for IoT hubs that have either `-toasters-` or `-heatpumps-` in their names. If you change the suggested values, make sure to use names that contain the required substrings.
> The commands used in this tutorial create resources in the West US location by default. We recommend that you create your resources in the region nearest you that supports Device Provisioning Service. You can view a list of available locations by going to the [Azure Status](https://azure.microsoft.com/status/) page and searching for "Device Provisioning Service". In commands, locations can be specified either in one word or multi-word format; for example: westus, West US, WEST US, etc. The value is not case sensitive.
80
76
@@ -113,53 +109,53 @@ In this section, you use the Azure Cloud Shell to create a provisioning service
113
109
5. Run the following two commands to get the connection strings for the hubs you created.
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.
130
126
131
-
1. Sign in to the [Azure portal](https://portal.azure.com). From your home page, select **+ Create a resource**.
132
-
133
-
2. In the *Search the Marketplace* search box, type "Function App". From the drop-down list select **Function App**, and then select **Create**.
134
-
135
-
3. On the **Function App** create page, under the **Basics** tab, enter the following settings for your new function app and select **Review + create**:
136
-
137
-
**Resource Group**: Select the **contoso-us-resource-group** to keep all resources created in this tutorial together.
138
-
139
-
**Function App name**: Enter a unique function app name. This example uses **contoso-function-app-1098**.
127
+
1. Sign in to the [Azure portal](https://portal.azure.com).
140
128
141
-
**Publish**: Verify that **Code** is selected.
129
+
1. In the search box, search for and select **Function App**.
142
130
143
-
**Runtime Stack**: Select **.NET** from the drop-down.
131
+
1. Select **Create** or **Create Function App**.
144
132
145
-
**Version**: Select **3.1** from the drop-down.
133
+
1. On the **Function App** create page, under the **Basics** tab, enter the following settings for your new function app and select **Review + create**:
146
134
147
-
**Region**: Select the same region as your resource group. This example uses **West US**.
| **Subscription** | Make sure that the subscription where you created the resources for this tutorial is selected. |
138
+
| **Resource Group** | Select the resource group that you created in the previous section. The default is **contoso-us-resource-group**. |
139
+
| **Function App name** | Provide a name for your function app. |
140
+
| **Publish** | Code |
141
+
| **Runtime Stack** | .NET |
142
+
| **Version** | 3.1 |
143
+
| **Region** | West US |
148
144
149
145
> [!NOTE]
150
146
> By default, Application Insights is enabled. Application Insights is not necessary for this tutorial, but it might help you understand and investigate any issues you encounter with the custom allocation. If you prefer, you can disable Application Insights by selecting the **Monitoring** tab and then selecting **No** for **Enable Application Insights**.
151
147
152
148

153
149
154
-
4. On the **Summary** page, select **Create** to create the function app. Deployment may take several minutes. When it completes, select **Go to resource**.
150
+
1. On the **Summary** page, select **Create** to create the function app. Deployment may take several minutes. When it completes, select **Go to resource**.
155
151
156
-
5. On the left pane of the function app **Overview** page, select **Functions** and then **+ Create** to add a new function.
152
+
1. On the left pane of the function app **Overview** page, select **Functions** and then **+ Create** to add a new function.
157
153
158
-
6. On the **Create function** page, make sure that **Development environment** is set to **Develop in portal**. Then select the **HTTP Trigger** template followed by the **Create** button.
154
+
1. On the **Create function** page, make sure that **Development environment** is set to **Develop in portal**. Then select the **HTTP Trigger** template followed by the **Create** button.
159
155
160
-
7. When the **HttpTrigger1** function opens, select **Code + Test** on the left pane. This allows you to edit the code for the function. The **run.csx** code file should be opened for editing.
156
+
1. When the **HttpTrigger1** function opens, select **Code + Test** on the left pane. This allows you to edit the code for the function. The **run.csx** code file should be opened for editing.
161
157
162
-
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.proj* file. In this step, you save and upload a *function.proj* file for the required assemblies. For more information, see [Using NuGet packages with Azure Functions](../azure-functions/functions-reference-csharp.md#using-nuget-packages).
158
+
1. 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.proj* file. In this step, you save and upload a *function.proj* file for the required assemblies. For more information, see [Using NuGet packages with Azure Functions](../azure-functions/functions-reference-csharp.md#using-nuget-packages).
163
159
164
160
1. Copy the following lines into your favorite editor and save the file on your computer as *function.proj*.
165
161
@@ -175,11 +171,11 @@ In this section, you create an Azure function that implements your custom alloca
175
171
</Project>
176
172
```
177
173
178
-
2. Select the **Upload** button located above the code editor to upload your *function.proj* file. After uploading, select the file in the code editor using the drop-down box to verify the contents.
174
+
1. Select the **Upload** button located above the code editor to upload your *function.proj* file. After uploading, select the file in the code editor using the drop-down box to verify the contents.
179
175
180
-
3. Select the *function.proj* file in the code editor and verify its contents. If the *function.proj* file is empty copy the lines above into the file and save it. (Sometimes the upload will create the file without uploading the contents.)
176
+
1. Select the *function.proj* file in the code editor and verify its contents. If the *function.proj* file is empty copy the lines above into the file and save it. (Sometimes the upload will create the file without uploading the contents.)
181
177
182
-
9. Make sure *run.csx* for **HttpTrigger1** is selected in the code editor. Replace the code for the **HttpTrigger1** function with the following code and select **Save**:
178
+
1. Make sure *run.csx* for **HttpTrigger1** is selected in the code editor. Replace the code for the **HttpTrigger1** function with the following code and select **Save**:
0 commit comments