Description
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