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.35k stars 4.71k forks source link

[BUG] LinkedIntegrationRuntimeType does not deserialize "Rbac" authorizationType properly #43352

Open agintegrated opened 5 months ago

agintegrated commented 5 months ago

Library name and version

Azure.ResourceManager.DataFactory 1.1.0-beta.1

Describe the bug

The management.azure.com API returns a response with the authorizationType in title case for "Rbac".
The LinkedIntegrationRuntimeType.DeserializeLinkedIntegrationRuntimeType() method is hard-coded to only check for "RBAC" in all-caps.
This causes the UnknownLinkedIntegrationRuntimeType to be returned instead of the correct LinkedIntegrationRuntimeRbacAuthorization type.

The fix for this can be added to azure-sdk-for-net\sdk\datafactory\Azure.ResourceManager.DataFactory\src\Generated\Models\LinkedIntegrationRuntimeType.Serialization.cs Find the DeserializeLinkedIntegrationRuntimeType() method (around line 61)

Add an additional case for "Rbac" as follows: switch (discriminator.GetString()) { case "Key": return LinkedIntegrationRuntimeKeyAuthorization.DeserializeLinkedIntegrationRuntimeKeyAuthorization(element, options); case "Rbac": case "RBAC": return LinkedIntegrationRuntimeRbacAuthorization.DeserializeLinkedIntegrationRuntimeRbacAuthorization(element, options); }

Expected behavior

The LinkedIntegrationRuntimeType.DeserializeLinkedIntegrationRuntimeType() method should return an instance of type LinkedIntegrationRuntimeRbacAuthorization when the authorizationType is equal to "Rbac".

Actual behavior

The LinkedIntegrationRuntimeType.DeserializeLinkedIntegrationRuntimeType() method returns an instance of type UnknownLinkedIntegrationRuntimeType when the authorizationType is equal to "Rbac".

Reproduction Steps

Configure a Data Factory with a linked self hosted integration runtime per the following instructions: https://learn.microsoft.com/en-us/azure/data-factory/create-shared-self-hosted-integration-runtime-powershell#create-a-linked-self-hosted-integration-runtime

Use the API to get the DataFactoryIntegrationRuntimeResource and drill down into the runtime.Data.Properties.LinkedInfo. This object should be an instance of LinkedIntegrationRuntimeRbacAuthorization with the same ResourceId as was configured for the shared runtime.

Environment

.NET SDK: Version: 7.0.401 Commit: eb26aacfec

Runtime Environment: OS Name: Windows OS Version: 10.0.19045 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.401\

Host: Version: 7.0.11 Architecture: x64 Commit: ecb34f85ec

jsquire commented 5 months ago

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

wangbwn commented 5 months ago

Currently, we should only have released version 1.0.0 of Azure.ResourceManager.DataFactory. Can you like to switch to version 1.0.0 and give it a try?

agintegrated commented 5 months ago

I had tried 1.0.0 initially which is why I tried the 1.1.0 beta version without success.
It appears that the 1.0.0 version has the same problem where it only looks for upper case "RBAC": https://github.com/Azure/azure-sdk-for-net/blob/Azure.ResourceManager.DataFactory_1.0.0/sdk/datafactory/Azure.ResourceManager.DataFactory/src/Generated/Models/LinkedIntegrationRuntimeType.Serialization.cs#L74