Skip to content

Add API version 2025-05-01 for dnsresolver #49921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

jamesvoongms
Copy link
Member

@jamesvoongms jamesvoongms commented May 8, 2025

Contributing to the Azure SDK

Please see our CONTRIBUTING.md if you are not familiar with contributing to this repository or have questions.

For specific information about pull request etiquette and best practices, see this section.

This is current draft PR for the API changes in dns-resolver-ga-version-2025-05-01
Azure/azure-rest-api-specs#34457

The PR adds upon the public preview with a new POST request for the domain list resource. Also smaller changes such as removing required properties and the blockresponsecode of the DNS security rule.

Release Plan: (https://apps.powerapps.com/play/e/ed2ffefd-774d-40dd-ab23-7fff01aeec9f/a/821ab569-ae60-420d-8264-d7b5d5ef734c?tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47)

@github-actions github-actions bot added the Mgmt This issue is related to a management-plane library. label May 8, 2025
@azure-sdk
Copy link
Collaborator

azure-sdk commented May 8, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

Azure.ResourceManager.DnsResolver

@jamesvoongms jamesvoongms force-pushed the dns-resolver-ga-version-2025-05-01 branch from 82e5412 to e82004e Compare May 13, 2025 06:02
@jamesvoongms jamesvoongms changed the title [DRAFT] Add API version 2025-05-01 for dnsresolver Add API version 2025-05-01 for dnsresolver May 13, 2025
@jamesvoongms
Copy link
Member Author

Currently having issues with the virtual network resource in the generation:

Autorest.md
partial-resources:
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}: VirtualNetwork

This seems to cause the generated examples to use a function that is only internal.

eg.
/mnt/vss/_work/1/s/sdk/dnsresolver/Azure.ResourceManager.DnsResolver/samples/Generated/Samples/Sample_VirtualNetworkDnsResolverResource.cs(37,104): error CS0117: 'VirtualNetworkDnsResolverResource' does not contain a definition for 'CreateResourceIdentifier'

@jamesvoongms jamesvoongms marked this pull request as ready for review May 13, 2025 07:58
@Copilot Copilot AI review requested due to automatic review settings May 13, 2025 07:58
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces API version 2025-05-01 for the dnsresolver service to support a new POST bulk API for large domain list usage, along with several supporting changes.

  • Removed the BlockResponseCode property from DNS security rule actions in tests and API definitions.
  • Updated the creation of DnsResolverDomainListData by moving from a constructor parameter to using the Domains collection.
  • Changed the DefaultLocation in tests from AustraliaEast to WestUS2, and updated metadata in autorest.md, assets.json, and CHANGELOG.md accordingly.

Reviewed Changes

Copilot reviewed 81 out of 81 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
VirtualNetworkLinkTests.cs, OutboundEndpointTests.cs, InboundEndpointTests.cs, DnsForwardingRulesetTests.cs Adjusted constructor comments for consistent formatting.
DnsSecurityRuleTests.cs Updated tests to remove the BlockResponseCode property from action creation.
DnsResolverDomainListTests.cs Modified domain list initialization to populate the Domains collection after construction; added tests for empty domain lists and bulk operations.
DnsResolverTestBase.cs Changed DefaultLocation from AustraliaEast to WestUS2.
autorest.md, assets.json Updated API version tags and related metadata.
API files (netstandard2.0.cs, net8.0.cs) Removed the BlockResponseCode property and replaced action property with ActionType, as well as added bulk API endpoints.
CHANGELOG.md Documented the new API version and bulk API feature.
Comments suppressed due to low confidence (1)

sdk/dnsresolver/Azure.ResourceManager.DnsResolver/api/Azure.ResourceManager.DnsResolver.netstandard2.0.cs:883

  • The BlockResponseCode property has been removed in favor of using ActionType only. Confirm that all client code and documentation have been updated accordingly to reflect this breaking change.
public Azure.ResourceManager.DnsResolver.Models.BlockResponseCode? BlockResponseCode { get { throw null; } set { } }

@@ -58,7 +59,7 @@ public async Task CreateDnsSecurityRule()
// ARRANGE
var dnsSecurityRuleName = Recording.GenerateAssetName("dnsSecurityRule-");
await CreateDnsResolverCollection();
Copy link
Preview

Copilot AI May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the BlockResponseCode property from the DnsSecurityRuleAction requires that both tests and documentation explicitly acknowledge this breaking change. Consider updating any relevant comments or documentation to clarify the new usage.

Suggested change
await CreateDnsResolverCollection();
await CreateDnsResolverCollection();
// The BlockResponseCode property has been removed from DnsSecurityRuleAction.
// The ActionType property should now be used to specify the desired action (e.g., Block).

Copilot uses AI. Check for mistakes.

Copy link
Member Author

@jamesvoongms jamesvoongms May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added breaking change comment, customers can no longer specify the blockresponsecode, tests also reflect this.

@jamesvoongms
Copy link
Member Author

jamesvoongms commented May 13, 2025

@ArthurMa1978 , could you help confirm the compilation error seen is the same as Azure/autorest.csharp#5134 ?

Edit: I have moved the bad generation to the customized folder and made the relevant function public instead of internal as a temporary fix.

@jamesvoongms jamesvoongms requested review from jsquire and a team as code owners May 14, 2025 21:39
jamesvoongms and others added 2 commits May 14, 2025 14:48
Moving down the dnsresolver sections

Co-authored-by: Jesse Squire <[email protected]>
@jamesvoongms jamesvoongms requested a review from jsquire May 14, 2025 22:10
Copy link
Member

@jsquire jsquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CODEOWNERS updates look good. @ArthurMa1978's team will need to review the library implementation.

@@ -571,7 +574,7 @@ protected DnsSecurityRuleCollection() { }
public partial class DnsSecurityRuleData : Azure.ResourceManager.Models.TrackedResourceData, System.ClientModel.Primitives.IJsonModel<Azure.ResourceManager.DnsResolver.DnsSecurityRuleData>, System.ClientModel.Primitives.IPersistableModel<Azure.ResourceManager.DnsResolver.DnsSecurityRuleData>
{
public DnsSecurityRuleData(Azure.Core.AzureLocation location, int priority, Azure.ResourceManager.DnsResolver.Models.DnsSecurityRuleAction action, System.Collections.Generic.IEnumerable<Azure.ResourceManager.Resources.Models.WritableSubResource> dnsResolverDomainLists) { }
public Azure.ResourceManager.DnsResolver.Models.DnsSecurityRuleAction Action { get { throw null; } set { } }
public Azure.ResourceManager.DnsResolver.Models.DnsSecurityRuleActionType? ActionType { get { throw null; } set { } }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as I could see here, this property changes its name, and become an optional property.
This is a breaking change that is simple to mitigate therefore we do not need to bump the major version for such a minor change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so by offline sync, I see this change was caused by that we removed a property on the DnsSecurityRuleAction model.
And now this model only has one property which triggers the mechanism in the generator to "flatten" it. In the meantime, the generator will hide the original property.
Therefore we saw this change, which is actually: the previous DnsSecurityRuleAction Action property is changed to internal, and a new public property DnsSecurityRuleActionType? ActionType was added.

@@ -895,7 +911,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer
public partial class DnsSecurityRulePatch : System.ClientModel.Primitives.IJsonModel<Azure.ResourceManager.DnsResolver.Models.DnsSecurityRulePatch>, System.ClientModel.Primitives.IPersistableModel<Azure.ResourceManager.DnsResolver.Models.DnsSecurityRulePatch>
{
public DnsSecurityRulePatch() { }
public Azure.ResourceManager.DnsResolver.Models.DnsSecurityRuleAction Action { get { throw null; } set { } }
public Azure.ResourceManager.DnsResolver.Models.DnsSecurityRuleActionType? ActionType { get { throw null; } set { } }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is triggering the breaking change, we just need to change it back on the SDK side.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To resolve this, I think you need to do this following this step:

  1. in your autorest.md, find an empty place and add this:
mgmt-debug:
   show-serialized-names: true
  1. regenerate the library.
  2. now you should be able to see a lot of debugging information showing up in the xml doc of every member and type, in this generated library, for this ActionType in DnsSecurityRulePath class, you should see in its xml doc, we have (for instance, you need to see its real value by actually running it) Serialized Name: XXX.YYY
  3. put that XXX.YYY into the rename-mapping section in autorest.md file like this:
rename-mapping:
   XXX.YYY: Action
  1. regenerate the library. Now you should see the property name has been changed by to Action.

And we could do the same for the type DnsSecurityRuleActionType, by adding a similar entry to rename-mapping to change its name back to DnsSecurityRuleAction.

This also leaves the breaking change of this being changed to nullable - let us figure out the changes above and then I could show you how to do it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to cause issues with the the dotnet build, is it possible I need to make modifications to the existing rename-mappings instead?\

rename-mapping:
ProvisioningState: DnsResolverProvisioningState
ForwardingRule: DnsForwardingRule
ForwardingRuleState: DnsForwardingRuleState
ForwardingRule.properties.forwardingRuleState: DnsForwardingRuleState
ForwardingRulePatch.properties.forwardingRuleState: DnsForwardingRuleState
InboundEndpoint: DnsResolverInboundEndpoint
IpConfiguration: InboundEndpointIpConfiguration
IpAllocationMethod: InboundEndpointIPAllocationMethod
OutboundEndpoint: DnsResolverOutboundEndpoint
VirtualNetworkLink: DnsForwardingRulesetVirtualNetworkLink
ActionType: DnsSecurityRuleActionType
Action: DnsResolverDomainListBulkAction

Error when adding
DnsSecurityRuleAction.actionType: Action

PS C:\Git\jamesvoong-azure-sdk-for-net\sdk\dnsresolver\Azure.ResourceManager.DnsResolver> dotnet build /t:GenerateCode
Restore complete (0.9s)
Azure.ResourceManager.DnsResolver failed with 2 error(s) (10.8s)
EXEC : error | error : Plugin csharpgen reported failure.
Q:.tools.nuget\packages\microsoft.azure.autorest.csharp\3.0.0-beta.20250512.2\buildMultiTargeting\Microsoft.Azure.AutoRest.CSharp.targets(59,5): error MSB3073: The command "npx autorest@ --max-memory-size=8192 --skip-csproj --skip-upgrade-check --version=3.9.7 C:\Git\jamesvoong-azure-sdk-for-net\sdk\dnsresolver\Azure.ResourceManager.DnsResolver\src/autorest.md --use=Q:.tools.nuget\packages\microsoft.azure.autorest.csharp\3.0.0-beta.20250512.2\buildMultiTargeting../tools/net9.0/any/ --clear-output-folder=true --shared-source-folders="C:\Git\jamesvoong-azure-sdk-for-net\eng/../sdk/core/Azure.Core/src/Shared/;Q:.tools.nuget\packages\microsoft.azure.autorest.csharp\3.0.0-beta.20250512.2\buildMultiTargeting../content/Generator.Shared/" --output-folder=C:\Git\jamesvoong-azure-sdk-for-net\sdk\dnsresolver\Azure.ResourceManager.DnsResolver\src/Generated --namespace=Azure.ResourceManager.DnsResolver" exited with code 1.

@@ -865,7 +882,6 @@ public partial class DnsSecurityRuleAction : System.ClientModel.Primitives.IJson
{
public DnsSecurityRuleAction() { }
public Azure.ResourceManager.DnsResolver.Models.DnsSecurityRuleActionType? ActionType { get { throw null; } set { } }
public Azure.ResourceManager.DnsResolver.Models.BlockResponseCode? BlockResponseCode { get { throw null; } set { } }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a breaking change.
In order to find a way to mitigate it, I need to know what happened to this property. Could you share some information about how this property changed in your spec?
We removed it in the latest api-version, I know this for sure.
Would the older existing api-versions still support this property? Or this property is a mistake from its first day.
The answer to these questions could change the way how we mitigate this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the older existing api-versions will support this property.

For more details, this property essentially is ignored on the control plane side, whatever the customer provides in this field is ignored and defaulted to a different value, and so the intention is to remove it.

Even on the old API versions, the value is being ignored on the old api versions but we are allowing customers to provide the parameter on old API versions.

Ideally we would like to remove it on all API versions as it being ignored in all API versions in the control plane standpoint.

Copy link
Member

@ArcturusZhang ArcturusZhang May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the case, we need to introduce this property back to mitigate the breaking change:
Please create a partial class in src/Customization or src/Custom directory for this class:

namespace Azure.ResourceManager.DnsResolver.Models
{
	[CodeGenSerialization(nameof(BlockResponseCode), "blockResponseCode")]
	public partial class DnsSecurityRuleAction
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public BlockResponseCode? BlockResponseCode { get; set; }
	}
}

The EditorBrowsable attribute hides this property from the intellisence so that new users would not see it, and the CodeGenSerialization attribute lets the generator know about how to serialize/deserialize this property into/from the payload to make sure the generated SDK could work with previous API versions.

During this process, the type of this property BlockResponseCode may also be deleted in this update, please find the removed file from git history and move it to the src/Customization or src/Custom directory.
After you have introduced the above code, please run the dotnet build /t:GenerateCode command to regenerate everything.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the deleted blockresponsecode.cs back into customization and the dnsSecurityRuleACtion but these seems to cause issues in the generator

PS C:\Git\jamesvoong-azure-sdk-for-net\sdk\dnsresolver\Azure.ResourceManager.DnsResolver> dotnet build /t:GenerateCode
Restore complete (1.1s)
Azure.ResourceManager.DnsResolver failed with 2 error(s) (11.3s)
EXEC : error | error : Plugin csharpgen reported failure.
Q:.tools.nuget\packages\microsoft.azure.autorest.csharp\3.0.0-beta.20250512.2\buildMultiTargeting\Microsoft.Azure.AutoRest.CSharp.targets(59,5): error MSB3073: The command "npx autorest@ --max-memory-size=8192 --skip-csproj --skip-upgrade-check --version=3.9.7 C:\Git\jamesvoong-azure-sdk-for-net\sdk\dnsresolver\Azure.ResourceManager.DnsResolver\src/autorest.md --use=Q:.tools.nuget\packages\microsoft.azure.autorest.csharp\3.0.0-beta.20250512.2\buildMultiTargeting../tools/net9.0/any/ --clear-output-folder=true --shared-source-folders="C:\Git\jamesvoong-azure-sdk-for-net\eng/../sdk/core/Azure.Core/src/Shared/;Q:.tools.nuget\packages\microsoft.azure.autorest.csharp\3.0.0-beta.20250512.2\buildMultiTargeting../content/Generator.Shared/" --output-folder=C:\Git\jamesvoong-azure-sdk-for-net\sdk\dnsresolver\Azure.ResourceManager.DnsResolver\src/Generated --namespace=Azure.ResourceManager.DnsResolver" exited with code 1.

Build failed with 2 error(s) in 12.7s

Workload updates are available. Run dotnet workload list for more information.

@ArcturusZhang ArcturusZhang marked this pull request as draft May 22, 2025 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mgmt This issue is related to a management-plane library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants