Search code examples
azurepowershellazure-devopsazure-iot-hubaz

Add-AzIotHubRoutingEndpoint cmdlet


I need to create some custom Endpoints for my Iot Hub through PowerShell. The cmdlet Add-AzIotHubRoutingEndpoint isn't sufficient since it doesn't provide the possibility to customize the BatchFrequencyInSeconds and the MaxChunkSizeInBytes properties.

Can this be achieved somehow?


Solution

  • I found a solution. The Set-AzIotHub has a parameter -RoutingProperties and in this way you can achieve greater customization. What I did was the following:

    # Create an endpoint object
    $customEndpoint = New-Object "Microsoft.Azure.Commands.Management.IotHub.Models.PSRoutingStorageContainerEndpoint"
    # Set its contents...
    
    # Get the routing properties from your Iot Hub
    $routingProperties = $iotHub.Properties.Routing
    # Add this endpoint to the specified category, mine was a storage container endpoint
    $routingProperties.Endpoints.StorageContainers.Add($customEndpoint)
    
    # Then call Set-AzIotHub
    $iotHub = Set-AzIotHub `
        -ResourceGroupName $ResourceGroupName `
        -Name "$($ResourceGroupName)$($IotHubSettings.NameSuffix)" `
        -RoutingProperties $routingProperties