Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure CLI Enrollment Group Update unlinks all IoT Hubs #29002

Closed
cboschert1 opened this issue May 21, 2024 · 7 comments
Closed

Azure CLI Enrollment Group Update unlinks all IoT Hubs #29002

cboschert1 opened this issue May 21, 2024 · 7 comments
Assignees
Labels
Auto-Assign Auto assign by bot Auto-Resolve Auto resolve by bot bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Issues that are reported by GitHub users external to the Azure organization. IoT/CLI IoT Service Attention This issue is responsible by Azure service team.

Comments

@cboschert1
Copy link

Describe the bug

When I update the allocation policy using the update enrollment-group command, it unlinks all IoT Hubs from the enrollment group.

Related command

az iot dps enrollment-group update -n -g <resource_group> --enrollment-id --allocation-policy custom --webhook-url --api-version 2021-10-01

Errors

Command succeeds and updates the allocation policy.

Issue script & Debug output

Please message if needed, don't want to have to go through the output and block sensitive info.

Expected behavior

I expect all other settings to stay the same on the enrollment group, and all of the selected linked hubs to remain unchanged.
Before the command:
image
After the command:
image

Environment Summary

{
"azure-cli": "2.52.0",
"azure-cli-core": "2.52.0",
"azure-cli-telemetry": "1.1.0",
"extensions": {
"azure-devops": "0.26.0",
"azure-iot": "0.23.1"
}
}

Additional context

Am I misunderstanding the update command. I expect an update command to only update the parameters I pass in, leaving everything else unchanged.

@cboschert1 cboschert1 added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label May 21, 2024
Copy link

Hi @cboschert1,

2.52.0 is not the latest Azure CLI(2.61.0).

If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

@azure-client-tools-bot-prd azure-client-tools-bot-prd bot added the Auto-Resolve Auto resolve by bot label May 21, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. IoT Service Attention This issue is responsible by Azure service team. Auto-Assign Auto assign by bot IoT/CLI labels May 21, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented May 21, 2024

Thank you for opening this issue, we will look into it.

Copy link
Contributor

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/azure-iot-cli-triage.

@cboschert1
Copy link
Author

Hi @cboschert1,

2.52.0 is not the latest Azure CLI(2.61.0).

If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

Verified this happens with the latest azure CLI (2.61.0) as well.

@vilit1
Copy link
Contributor

vilit1 commented May 21, 2024

Hi,

I managed to reproduce your issue and have looked into the code and documentation as to why this occurs. The initial goal was to have the customer re-enter the IoT Hubs they want to connect if they change the allocation policy. This is extremely important for allocation policies such as static, in which exactly one IoT Hub is allowed.

However, I can see this being a pain point, especially if there are multiple IoT Hubs present and the allocation policy is minimally changed (such as updating the webhook url). Thus, I will modify the enrollment update code so that the current IoT Hub list is kept unless a new one is specified via the command.

@cboschert1
Copy link
Author

Thank you for the quick response, I appreciate it and will follow this issue for updates.

In the meantime I did this as a workaround if someone else happens across this. There's probably a better way, but this works for now:

enrollmentGroupInfo=$(az iot dps enrollment-group show -g $RESOURCE_GROUP --dps-name $DPS_NAME --enrollment-id $group)
linkedHubs=$(echo $enrollmentGroupInfo | jq -r '.iotHubs[]' | xargs)
...
az iot dps enrollment-group update -g $RESOURCE_GROUP --dps-name $DPS_NAME --enrollment-id $group --iot-hubs "$linkedHubs" --allocation-policy custom --webhook-url $FUNCTION_URL --api-version 2021-10-01

@vilit1
Copy link
Contributor

vilit1 commented Jul 31, 2024

Closing issue since the code has been merged in and released

@vilit1 vilit1 closed this as completed Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot Auto-Resolve Auto resolve by bot bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Issues that are reported by GitHub users external to the Azure organization. IoT/CLI IoT Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

3 participants