0

I'm new to both Terraform and Azure. In a timespan of 6 weeks I have to create an IoT solution. I've only got 3 weeks left.

I have to provision devices in an IoT hub using a DPS and if 'm not wrong, a DPS uses azure functions to do so.

My question is, how can I add azure functions to a dps using terraform or is this not possible and do I have it all wrong?

1 Answers1

1

DPS does not require an Azure Function for basic functionality. That's only needed if you're doing custom allocation policies. If all you want to do is have an IoT Hub assigned from a pool of one or more Hubs, then one of the built-in allocation policies will work, as described in the overview:

Multiple allocation policies to control how DPS assigns devices to IoT hubs in support of your scenarios: Lowest latency, evenly weighted distribution (default), and static configuration via the enrollment list. Latency is determined using the same method as Traffic Manager.

The documentation explains how to select this in the Portal, and since you mention you're using Terraform, the provider does this using the allocation_policy setting according to the provider documentation.

I understand you're under a small time crunch but you might find the self-paced training at Microsoft Learn for the AZ-220 exam worth your time. There is a learning path about device provisioning, and the information on load balancing is covered in that (for example, at this lesson).

MikeBaz - MSFT
  • 2,938
  • 4
  • 28
  • 57
  • I would be interested if there's a way of using Terraform to actually set `allocation_policy` to Azure Function. It is not mentioned it in the documentation you linked, it only mentions the other options: `Hashed`, `GeoLatency` or `Static`. – SysGen Feb 25 '22 at 10:15
  • that feels like a separate question but in any event, reading the provider source at https://github.com/hashicorp/terraform-provider-azurerm/blob/807f0fd916fa81e0cdb3a5c411010c5e5842d59c/internal/services/iothub/iothub_dps_resource.go#L174 line 174, you can't right now. Probably worth opening an issue if you're looking for that capability, – MikeBaz - MSFT Feb 26 '22 at 14:54