Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.17k stars 4.53k forks source link

[BUG] Fails to find existing Host resource in a Resource Group #44157

Closed AlexLsh closed 1 day ago

AlexLsh commented 1 month ago

Library name and version

Azure.ResourceManager.Maintenance v1.1.2

Describe the bug

It appears that the call to CreateOrUpdateConfigurationAssignmentAsync() behaves differently based on whether the resource type (as passed to that call) has parent/child resource types, like: "hostGroups/hosts" or when there's just a resource type name, like: "virtualMachines"

For the virtual machine resource, when there's a resource missing (like a virtual machine not present in a RG), the error message would be: The Resource 'Microsoft.Compute/virtualMachines/maintenanceconfigurationtest' under resource group 'fsavs3wcus-rupatro-mgmt' was not found. Note the resource name looks like expected: Provider/Type/name.

For the host resource, in the scenario when the required resource was actually present in an RG, the error message was: The Resource 'Microsoft.Compute/hostGroups/hosts' under resource group 'fsavs3wcus-vis-proto-mgmt' was not found. Note that the resource name (esx-1) is not present in the error message.

It looks like CreateOrUpdateConfigurationAssignmentAsync() fails to understand, that 'Microsoft.Compute/hostGroups/hosts' is not a full resource name. And, when it tries to lookup with 'Microsoft.Compute/hostGroups/hosts' the resoource whose name is actually 'Microsoft.Compute/hostGroups/hosts/esx-1', it of course fails.

Expected behavior

When called to add an existing Host resource the function should add it to the MC, just as New-AzConfigurationAssignment does. I was able to verify that the New-AzConfigurationAssignment would add the Hosts to the MCs in the resource groups, where CreateOrUpdateConfigurationAssignmentAsync() as describe above.

Actual behavior

As describe above, CreateOrUpdateConfigurationAssignmentAsync() fails to add exisring Host to existing Maintenance Configuration (MC).

Reproduction Steps

  1. In a Resource Group, create a Host group, with at least one Host.
  2. Create Maintenance Configuration in the Resource Group.
  3. Try to add the host (from the above Host Group), to the MC from step 2.4
  4. It will succeed from Portal web UI, it would succeed with New-AzConfigurationAssignment, and CreateOrUpdateConfigurationAssignmentAsync() would fail as described in the Bug Description Section.

Environment

An Azure Subscription.

github-actions[bot] commented 1 month ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.

HarveyLink commented 3 weeks ago

Hi @AlexLsh , Thank you for using Azure SDK for .Net. I can't 100% go through your scenaro since we don' have much domain knowledge on a specific service. However, the usage of this method should looks like: await resourceGroup.CreateOrUpdateConfigurationAssignmentAsync("Microsoft.Compute", "hostGroups/hostGroupName/hosts", "hostName", "resultName", data) I can't get further beacuse the service returns region not supported error, but there should avoid the Not Found error thrown.

github-actions[bot] commented 3 weeks ago

Hi @AlexLsh. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

github-actions[bot] commented 2 weeks ago

Hi @AlexLsh, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!