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

[BUG] Azure Resource Mover APIs do not work for Network interface resources #47729

Open
arjunbalgovind opened this issue Jan 6, 2025 · 1 comment
Assignees
Labels
ARM customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@arjunbalgovind
Copy link

Library name and version

Azure.ResourceManager.ResourceMover 1.1.1

Describe the bug

The MoverResourceSetResource.GetMoverResource and MoverResourceCollection.CreateOrUpdateAsync API does not seem to handle the JSON response/request if a NIC resource is passed correctly. The first one fails on deserializing the "IsOptional" field as it interprets "True" and "False" as strings. The second one fails if a private address field is an empty string as it attempts to parse it as System.Net.IpAddress, even though this is a valid value and would be the default if using the Azure Resource Mover from the Azure Portal.

Note that the exact same set of commands and configuration works with the Az PowerShell library,

Expected behavior

GetMoverResource should return the data model for an existing valid resource in a move collection, and CreateOrUpdateAsync should be able to successfully add a NIC to a move collection.

Actual behavior

GetMoverResource fails with the following exception:

System.InvalidOperationException: The requested operation requires an element of type 'Boolean', but the target element has type 'String'.
   at System.Text.Json.JsonElement.<GetBoolean>g__ThrowJsonElementWrongTypeException|17_0(JsonTokenType actualType)
   at System.Text.Json.JsonElement.GetBoolean()
   at Azure.ResourceManager.ResourceMover.Models.MoverResourceDependency.DeserializeMoverResourceDependency(JsonElement element)
   at Azure.ResourceManager.ResourceMover.Models.MoverResourceProperties.DeserializeMoverResourceProperties(JsonElement element)
   at Azure.ResourceManager.ResourceMover.MoverResourceData.DeserializeMoverResourceData(JsonElement element)
   at Azure.ResourceManager.ResourceMover.MoveResourcesRestOperations.Get(String subscriptionId, String resourceGroupName, String moverResourceSetName, String moverResourceName, CancellationToken cancellationToken)
   at Azure.ResourceManager.ResourceMover.MoverResourceCollection.Get(String moverResourceName, CancellationToken cancellationToken)
   at Azure.ResourceManager.ResourceMover.MoverResourceSetResource.GetMoverResource(String moverResourceName, CancellationToken cancellationToken)

CreateOrUpdateAsync fails with the following exception:

System.FormatException: An invalid IP address was specified.
[2025-01-06T18:29:54.682Z]  ---> System.Net.Sockets.SocketException (10022): An invalid argument was supplied.
[2025-01-06T18:29:54.684Z]    --- End of inner exception stack trace ---
[2025-01-06T18:29:54.686Z]    at System.Net.IPAddressParser.Parse(ReadOnlySpan`1 ipSpan, Boolean tryParse)
[2025-01-06T18:29:54.688Z]    at System.Net.IPAddress.Parse(String ipString)
[2025-01-06T18:29:54.689Z]    at Azure.ResourceManager.ResourceMover.Models.NicIPConfigurationResourceSettings.DeserializeNicIPConfigurationResourceSettings(JsonElement element)
[2025-01-06T18:29:54.691Z]    at Azure.ResourceManager.ResourceMover.Models.NetworkInterfaceResourceSettings.DeserializeNetworkInterfaceResourceSettings(JsonElement element)
[2025-01-06T18:29:54.693Z]    at Azure.ResourceManager.ResourceMover.Models.MoverResourceSettings.DeserializeMoverResourceSettings(JsonElement element)
[2025-01-06T18:29:54.695Z]    at Azure.ResourceManager.ResourceMover.Models.MoverResourceProperties.DeserializeMoverResourceProperties(JsonElement element)
[2025-01-06T18:29:54.697Z]    at Azure.ResourceManager.ResourceMover.MoverResourceData.DeserializeMoverResourceData(JsonElement element)
[2025-01-06T18:29:54.699Z]    at Azure.ResourceManager.ResourceMover.MoverResourceOperationSource.Azure.Core.IOperationSource<Azure.ResourceManager.ResourceMover.MoverResource>.CreateResultAsync(Response response, CancellationToken cancellationToken)

Reproduction Steps

For the issue with the GetMoverResource API:

ResourceGroupResource resourceGroup = (await armClient.GetSubscriptionResource(SubscriptionResource.CreateResourceIdentifier(subscriptionId)).GetResourceGroupAsync("my-test-rg")).Value;
MoverResourceSetResource moveCollection = (await resourceGroup.GetMoverResourceSets().GetAsync("my-test-moveCollection")).Value;
var res = moveCollection.GetMoverResource("vm-nic");

For the issue with the CreateOrUpdateAsync API:

// Add the NIC to the move collection
string sourceVnetId = $"/subscriptions/{subscriptionId}/resourceGroups/{srcResourceGroupName}/providers/Microsoft.Network/virtualNetworks/my-vnet";
string targetVnetId = $"/subscriptions/{subscriptionId}/resourceGroups/{targetResourceGroupName}/providers/Microsoft.Network/virtualNetworks/my-vnet";

MoverResourceData nicMoverResourceData = new()
{
    Properties = new MoverResourceProperties(sourceId: new ResourceIdentifier($"/subscriptions/{subscriptionId}/resourceGroups/{srcResourceGroupName}/providers/Microsoft.Network/networkInterfaces/{nicName}"))
    {
        ResourceSettings = new NetworkInterfaceResourceSettings()
        {
            TargetResourceName = nicName,
            TargetResourceGroupName = targetResourceGroupName,
        }
    },

};

// Use the existing VNet in the target region and resource group.
nicMoverResourceData.Properties.DependsOnOverrides.Add(new MoverResourceDependencyOverride()
{
    Id = new ResourceIdentifier(sourceVnetId),
    TargetId = new ResourceIdentifier(targetVnetId),
});

await moveCollection.GetMoverResources().CreateOrUpdateAsync(WaitUntil.Completed, nicName, nicMoverResourceData);

Environment

  • .NET 8.0
  • Visual Studio 17.12.3
@github-actions github-actions bot added ARM customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team. labels Jan 6, 2025
Copy link

github-actions bot commented Jan 6, 2025

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @anthony-c-martin @calecarter @cemheren @j5lim @majastrz.

@HarveyLink HarveyLink self-assigned this Jan 7, 2025
@mcgallan mcgallan assigned mcgallan and unassigned HarveyLink Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ARM customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

3 participants