Skip to content

Commit e5c153a

Browse files
committed
Add updates for feedback from nberdy, including latest UI changes
1 parent 0a03096 commit e5c153a

File tree

3 files changed

+37
-35
lines changed

3 files changed

+37
-35
lines changed

articles/iot-dps/how-to-use-custom-allocation-policies.md

+37-35
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ manager: timlt
1414
# How to use custom allocation policies
1515

1616

17-
A custom allocation policy gives you more control over how devices are assigned to an IoT hub. This is accomplished by using custom code in an [Azure Function](../azure-functions/functions-overview.md) to assign devices to an IoT hub. The device provisioning service calls your Azure Function code providing the IoT hub group. Your function code returns the IoT hub information for provisioning the device.
17+
A custom allocation policy gives you more control over how devices are assigned to an IoT hub. This is accomplished by using custom code in an [Azure Function](../azure-functions/functions-overview.md) to assign devices to an IoT hub. The device provisioning service calls your Azure Function code providing all relevant information about the device and the enrollment. Your function code is executed and returns the IoT hub information used to provisioning the device.
1818

1919
By using custom allocation policies you define your own allocation policies when the policies provided by the Device Provisioning Service do not meet the requirements of your scenario.
2020

@@ -103,7 +103,9 @@ In this section, you will create a new enrollment group that uses the custom all
103103
![Add custom allocation enrollment group for symmetric key attestation](./media/how-to-use-custom-allocation-policies/create-custom-allocation-enrollment.png)
104104
105105
106-
4. On **Add Enrollment Group**, click **Link a new IoT hub** to link both of your new divisional IoT hubs.
106+
4. On **Add Enrollment Group**, click **Link a new IoT hub** to link both of your new divisional IoT hubs.
107+
108+
You must execute this step for both of your divisional IoT hubs.
107109
108110
**Subscription**: If you have multiple subscriptions, choose the subscription where you created the divisional IoT hubs.
109111
@@ -274,9 +276,9 @@ In this section, you will create a new enrollment group that uses the custom all
274276
275277
In this section, you will create two unique device keys. One key will be used for a simulated toaster device. The other key will be used for a simulated heat pump device.
276278
277-
To generate the device key, use the **Primary Key** you noted earlier to compute the [HMAC-SHA256](https://wikipedia.org/wiki/HMAC) of the device registration ID for each device and convert the result into Base64 format.
279+
To generate the device key, you will use the **Primary Key** you noted earlier to compute the [HMAC-SHA256](https://wikipedia.org/wiki/HMAC) of the device registration ID for each device and convert the result into Base64 format. For more information on creating derived device keys with enrollment groups, see the group enrollments section of [Symmetric key attestation](concepts-symmetric-key-attestation.md).
278280
279-
Use the following two device registration IDs and compute a device key for both devices. Both registration IDs have a valid suffix to work with the example code for the custom allocation policy:
281+
For the example in this article, use the following two device registration IDs and compute a device key for both devices. Both registration IDs have a valid suffix to work with the example code for the custom allocation policy:
280282
281283
- **breakroom499-contoso-tstrsd-007**
282284
- **mainbuilding167-contoso-hpsd-088**
@@ -285,53 +287,53 @@ Use the following two device registration IDs and compute a device key for both
285287
286288
If you are using a Linux workstation, you can use openssl to generate your derived device keys as shown in the following example.
287289
288-
Replace the value of **KEY** with the **Primary Key** you noted earlier.
290+
1. Replace the value of **KEY** with the **Primary Key** you noted earlier.
289291
290-
```bash
291-
KEY=oiK77Oy7rBw8YB6IS6ukRChAw+Yq6GC61RMrPLSTiOOtdI+XDu0LmLuNm11p+qv2I+adqGUdZHm46zXAQdZoOA==
292+
```bash
293+
KEY=oiK77Oy7rBw8YB6IS6ukRChAw+Yq6GC61RMrPLSTiOOtdI+XDu0LmLuNm11p+qv2I+adqGUdZHm46zXAQdZoOA==
292294
293-
REG_ID1=breakroom499-contoso-tstrsd-007
294-
REG_ID2=mainbuilding167-contoso-hpsd-088
295+
REG_ID1=breakroom499-contoso-tstrsd-007
296+
REG_ID2=mainbuilding167-contoso-hpsd-088
295297
296-
keybytes=$(echo $KEY | base64 --decode | xxd -p -u -c 1000)
297-
devkey1=$(echo -n $REG_ID1 | openssl sha256 -mac HMAC -macopt hexkey:$keybytes -binary | base64)
298-
devkey2=$(echo -n $REG_ID2 | openssl sha256 -mac HMAC -macopt hexkey:$keybytes -binary | base64)
298+
keybytes=$(echo $KEY | base64 --decode | xxd -p -u -c 1000)
299+
devkey1=$(echo -n $REG_ID1 | openssl sha256 -mac HMAC -macopt hexkey:$keybytes -binary | base64)
300+
devkey2=$(echo -n $REG_ID2 | openssl sha256 -mac HMAC -macopt hexkey:$keybytes -binary | base64)
299301
300-
echo -e $"\n\n$REG_ID1 : $devkey1\n$REG_ID2 : $devkey2\n\n"
301-
```
302+
echo -e $"\n\n$REG_ID1 : $devkey1\n$REG_ID2 : $devkey2\n\n"
303+
```
302304
303-
```bash
304-
breakroom499-contoso-tstrsd-007 : JC8F96eayuQwwz+PkE7IzjH2lIAjCUnAa61tDigBnSs=
305-
mainbuilding167-contoso-hpsd-088 : 6uejA9PfkQgmYylj8Zerp3kcbeVrGZ172YLa7VSnJzg=
306-
```
305+
```bash
306+
breakroom499-contoso-tstrsd-007 : JC8F96eayuQwwz+PkE7IzjH2lIAjCUnAa61tDigBnSs=
307+
mainbuilding167-contoso-hpsd-088 : 6uejA9PfkQgmYylj8Zerp3kcbeVrGZ172YLa7VSnJzg=
308+
```
307309
308310
309311
#### Windows-based workstations
310312
311313
If you are using a Windows-based workstation, you can use PowerShell to generate your derived device key as shown in the following example.
312314
313-
Replace the value of **KEY** with the **Primary Key** you noted earlier.
315+
1. Replace the value of **KEY** with the **Primary Key** you noted earlier.
314316
315-
```PowerShell
316-
$KEY='oiK77Oy7rBw8YB6IS6ukRChAw+Yq6GC61RMrPLSTiOOtdI+XDu0LmLuNm11p+qv2I+adqGUdZHm46zXAQdZoOA=='
317+
```PowerShell
318+
$KEY='oiK77Oy7rBw8YB6IS6ukRChAw+Yq6GC61RMrPLSTiOOtdI+XDu0LmLuNm11p+qv2I+adqGUdZHm46zXAQdZoOA=='
317319
318-
$REG_ID1='breakroom499-contoso-tstrsd-007'
319-
$REG_ID2='mainbuilding167-contoso-hpsd-088'
320+
$REG_ID1='breakroom499-contoso-tstrsd-007'
321+
$REG_ID2='mainbuilding167-contoso-hpsd-088'
320322
321-
$hmacsha256 = New-Object System.Security.Cryptography.HMACSHA256
322-
$hmacsha256.key = [Convert]::FromBase64String($key)
323-
$sig1 = $hmacsha256.ComputeHash([Text.Encoding]::ASCII.GetBytes($REG_ID1))
324-
$sig2 = $hmacsha256.ComputeHash([Text.Encoding]::ASCII.GetBytes($REG_ID2))
325-
$derivedkey1 = [Convert]::ToBase64String($sig1)
326-
$derivedkey2 = [Convert]::ToBase64String($sig2)
323+
$hmacsha256 = New-Object System.Security.Cryptography.HMACSHA256
324+
$hmacsha256.key = [Convert]::FromBase64String($key)
325+
$sig1 = $hmacsha256.ComputeHash([Text.Encoding]::ASCII.GetBytes($REG_ID1))
326+
$sig2 = $hmacsha256.ComputeHash([Text.Encoding]::ASCII.GetBytes($REG_ID2))
327+
$derivedkey1 = [Convert]::ToBase64String($sig1)
328+
$derivedkey2 = [Convert]::ToBase64String($sig2)
327329
328-
echo "`n`n$REG_ID1 : $derivedkey1`n$REG_ID2 : $derivedkey2`n`n"
329-
```
330+
echo "`n`n$REG_ID1 : $derivedkey1`n$REG_ID2 : $derivedkey2`n`n"
331+
```
330332
331-
```PowerShell
332-
breakroom499-contoso-tstrsd-007 : JC8F96eayuQwwz+PkE7IzjH2lIAjCUnAa61tDigBnSs=
333-
mainbuilding167-contoso-hpsd-088 : 6uejA9PfkQgmYylj8Zerp3kcbeVrGZ172YLa7VSnJzg=
334-
```
333+
```PowerShell
334+
breakroom499-contoso-tstrsd-007 : JC8F96eayuQwwz+PkE7IzjH2lIAjCUnAa61tDigBnSs=
335+
mainbuilding167-contoso-hpsd-088 : 6uejA9PfkQgmYylj8Zerp3kcbeVrGZ172YLa7VSnJzg=
336+
```
335337
336338
337339
The simulated devices will use the derived device keys with each registration ID to perform symmetric key attestation.
Loading
Loading

0 commit comments

Comments
 (0)