Skip to content

[BUG] Serialization Error When Removing KeyVault Properties from Microsoft.OperationalInsights/clusters Resource #48747

Open
@johnib

Description

@johnib

Library name and version

Azure.ResourceManager.OperationalInsights 1.3.0-beta.1

Describe the bug

When attempting to remove the customer-managed key (CMK) configuration from a Microsoft.OperationalInsights/clusters resource by setting KeyVaultUri, KeyName, and KeyVersion to empty strings, the request fails with a serialization error. The error occurs because KeyVaultUri is assigned a relative URI (new Uri("", UriKind.Relative)), which is not supported for serialization.

Using this code:

var updateData = new OperationalInsightsClusterPatch
{
    KeyVaultProperties = new OperationalInsightsKeyVaultProperties
    {
        KeyVaultUri = new Uri("", UriKind.Relative),
        KeyName = "",
        KeyVersion = ""
    }
};

logger.LogInformationEx($"[{state.TestId}] Removing KeyVault properties from cluster {cluster.Id}");

// Update the cluster to remove KeyVault properties
var updateResponse = await cluster.UpdateAsync(
    Azure.WaitUntil.Completed,
    updateData,
    cancellationToken);

Which is meant to update an Microsoft.OperationalInsights/clusters resource, to remove the customer managed key (CMK) configuration fails on serialization issue:

System.InvalidOperationException: This operation is not supported for a relative URI.
  at System.Uri.get_AbsoluteUri
  at Azure.ResourceManager.OperationalInsights.Models.OperationalInsightsKeyVaultProperties.System.ClientModel.Primitives.IJsonModel<Azure.ResourceManager.OperationalInsights.Models.OperationalInsightsKeyVaultProperties>.Write
  at Azure.ResourceManager.OperationalInsights.ModelSerializationExtensions.WriteObjectValue
  at Azure.ResourceManager.OperationalInsights.Models.OperationalInsightsClusterPatch.System.ClientModel.Primitives.IJsonModel<Azure.ResourceManager.OperationalInsights.Models.OperationalInsightsClusterPatch>.Write
  at Azure.ResourceManager.OperationalInsights.ModelSerializationExtensions.WriteObjectValue
  at Azure.ResourceManager.OperationalInsights.ClustersRestOperations.CreateUpdateRequest
  at Azure.ResourceManager.OperationalInsights.ClustersRestOperations+<UpdateAsync>d__27.MoveNext

According to the docs, I have to explicitly set the KeyVaultUri, KeyName, KeyVersion to empty strings in order to remove the CMK configuration.

Setting KeyVaultProperties to null or omitting this field entirely -- is considered as "do not make any change to current configuration" by the API, even when called with PUT verb.

Expected behavior

Expected behavior is that the ArmClient SDK does not fail serializing the empty URI value.

Actual behavior

Actual behavior is that the ArmClient SDK fails to serialize the payload, because it tries to access the .AbsoluteUri property -- which is not supported for URIs being initialized with UriKind.Relative.

Reproduction Steps

Use this code:

var updateData = new OperationalInsightsClusterPatch
{
    KeyVaultProperties = new OperationalInsightsKeyVaultProperties
    {
        KeyVaultUri = new Uri("", UriKind.Relative),
        KeyName = "",
        KeyVersion = ""
    }
};

logger.LogInformationEx($"[{state.TestId}] Removing KeyVault properties from cluster {cluster.Id}");

// Update the cluster to remove KeyVault properties
var updateResponse = await cluster.UpdateAsync(
    Azure.WaitUntil.Completed,
    updateData,
    cancellationToken);

Environment

.NET SDK:
Version: 9.0.200
Commit: 90e8b202f2
Workload version: 9.0.200-manifests.b4a8049f
MSBuild version: 17.13.8+cbc39bea8

Runtime Environment:
OS Name: Mac OS X
OS Version: 15.3
OS Platform: Darwin
RID: osx-arm64
Base Path: /Users/jbarazany/.dotnet/sdk/9.0.200/

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
Version: 9.0.2
Architecture: arm64
Commit: 80aa709f5d

.NET SDKs installed:
6.0.428 [/Users/jbarazany/.dotnet/sdk]
8.0.404 [/Users/jbarazany/.dotnet/sdk]
9.0.200 [/Users/jbarazany/.dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.36 [/Users/jbarazany/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.11 [/Users/jbarazany/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.2 [/Users/jbarazany/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.36 [/Users/jbarazany/.dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.11 [/Users/jbarazany/.dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.2 [/Users/jbarazany/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

InsightsMgmtThis issue is related to a management-plane library.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions