Skip to content

[BUG] PublishAot = true does not work for Azure.ResourceManager.Dns #49498

Open
@mburumaxwell

Description

@mburumaxwell

Library name and version

Azure.ResourceManager.Dns 1.1.1

Describe the bug

When PublishAot is set to true, reading DNS records fails. Reading subscription, resource group, and the DNS zone still works.

Traced the bug down to this line:

systemData = JsonSerializer.Deserialize<ResourceManager.Models.SystemData>(property.Value.ToString());

Expected behavior

Ideally, deserializing SystemData should use key values or be skipped (seems to be the case to ResourceGroupResource)

Actual behavior

Exception is thrown:

System.InvalidOperationException: Reflection-based serialization has been disabled for this application. Either use the source generator APIs or explicitly configure the 'JsonSerializerOptions.TypeInfoResolver' property.

Reproduction Steps

Create a console application with AOT enabled or enable AoT in a console application.

var resourceGroupName = "<your-rg-name>";
var zoneName = "contuse.com";
var recordName = "office";

var credential = new DefaultAzureCredential();
var client = new ArmClient(credential);
var sub = armClient.GetDefaultSubscriptionAsync();

Azure.ResourceManager.Resources.ResourceGroupResource resourceGroup;
resourceGroup = await subscription.GetResourceGroupAsync(resourceGroupName, cancellationToken);

DnsZoneResource zone;
zone = await resourceGroup.GetDnsZoneAsync(zoneName, cancellationToken);

var aRecord = await zone.GetDnsARecordAsync(recordName, cancellationToken);

Environment

Runtime Environment:
OS Name: Mac OS X
OS Version: 15.4
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/9.0.203/

Visual Studio Code: 1.99.3

Metadata

Metadata

Assignees

Labels

MgmtThis issue is related to a management-plane library.Network - DNScustomer-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