Description
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:
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