Skip to content

[Resources] Added ExpandProperties functionality to GetAzureResourceGroup #28161

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

Merged
merged 35 commits into from
Jul 21, 2025

Conversation

a0x1ab
Copy link
Member

@a0x1ab a0x1ab commented Jul 10, 2025

Description

PR pertains to the following issues:

  1. [Feature]: Get-AzResourceGroup: Include createdTime and changedTime, at least optionally #27865
  2. Enable $expand for List Resources (Get-AzureRmResource or Find-AzureRmResource) #5814

This PR introduces the following changes:

  1. ResourceGroup endpoints now additionally request the $expand parameter to provide users with createdTime and changedTime properties for the GetAzureResource and GetAzureResourceGroup cmdlets respectively
  2. Added testing for GetAzureResourceGroup cmdlets to ensure the expanded properties are returned as expected
  3. Re-generated shared models and extensions
  4. Added examples and updated the help documentation for Get-AzResourceGroup
  5. Added examples for Get-AzResource

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

a0x1ab and others added 12 commits June 19, 2025 15:25
Test-AzResourceGroupDeployment output an empty warning as the conditionals were not accounting for all cases
Introduces new filter models (GenericResourceFilterWithExpand, ResourceGroupFilterWithExpand) and updates SDK interfaces and implementations to support the $expand query parameter for retrieving createdTime and changedTime on resources and resource groups. Updates related cmdlets and tests to validate the new properties.
@a0x1ab a0x1ab self-assigned this Jul 10, 2025
Copy link

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

@a0x1ab a0x1ab changed the title [Resources] Added expand functionality to GetAzureResource and GetAzureResourceGroup [Resources] Added expand functionality to GetAzureResource and GetAzureResourceGroup Jul 10, 2025
@a0x1ab a0x1ab marked this pull request as ready for review July 10, 2025 02:09
@Copilot Copilot AI review requested due to automatic review settings July 10, 2025 02:09
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 adds $expand support to the GetAzureResource and GetAzureResourceGroup cmdlets so that CreatedTime and ChangedTime are returned, and updates models, SDK clients, and tests accordingly.

  • Extend $expand parameter usage in OData queries and direct GET calls to include createdTime,changedTime
  • Augment PSResource/PSResourceGroup models and extensions with CreatedTime/ChangedTime
  • Add and update tests to verify expanded properties and update SDK transforms and changelog

Reviewed Changes

Copilot reviewed 10 out of 21 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Resources/Resources/ChangeLog.md Documented new expand functionality and fixed warnings
src/Resources/Resources.Test/ResourceGroups/GetAzureResourceGroupCommandTests.cs Added tests for timestamps on resource group cmdlet
src/Resources/Resources.Test/Resource/GetAzureResourceCommandTests.cs Updated tests to use expanded model and assert timestamps
src/Resources/Resources.Test/Models.ResourceGroups/ResourceClientTests.cs Updated mock setups to include $expand parameter
src/Resources/Resources.Management.Sdk/README.md Insert SDK readme transforms for $expand
src/Resources/ResourceManager/SdkModels/ResourceGroups/PSResourceGroup.cs Added CreatedTime and ChangedTime properties
src/Resources/ResourceManager/SdkExtensions/NewResourcesExtensions.cs Populate new timestamp properties in extension method
src/Resources/ResourceManager/SdkClient/ResourceManagerSdkClient.cs Change ListResources/ListByResourceGroup to use expanded filter
src/Resources/ResourceManager/SdkClient/NewResourceManagerSdkClient.cs Update FilterResourceGroups to set Expand and call GET with expand
src/Resources/ResourceManager/Implementation/Resource/GetAzureResourceCmdlet.cs Switch to expanded filter and set Expand in cmdlet
Comments suppressed due to low confidence (2)

src/Resources/Resources/ChangeLog.md:23

  • [nitpick] Add a space before the issue references, e.g. ...GetAzureResourceGroup [#5814] [#27865], for consistent formatting.
* Added functionality for cmdlet `GetAzureResource` and `GetAzureResourceGroup`[#5814][#27865]

src/Resources/Resources.Test/Resource/GetAzureResourceCommandTests.cs:76

  • [nitpick] Consider adding a test for the list (subscription-level) path of the Get-AzureResource cmdlet to verify CreatedTime and ChangedTime are returned when no ResourceId is provided.
        public void GetsResourcesById()

a0x1ab and others added 8 commits July 10, 2025 12:16
Introduces new filter models (GenericResourceFilterWithExpand, ResourceGroupFilterWithExpand) and updates SDK interfaces and implementations to support the $expand query parameter for retrieving createdTime and changedTime on resources and resource groups. Updates related cmdlets and tests to validate the new properties.
Fixed changelog
Deleted the GetsResourceGroupsWithTimestamps test, which duplicated the logic of an existing test. This reduces redundancy and simplifies the test suite.
@YanaXu
Copy link
Contributor

YanaXu commented Jul 10, 2025

Please fix the test errors. Don't forget to submit the recording files.

Copy link

This PR was labeled "needs-revision" because it has unresolved review comments or CI failures.
Please resolve all open review comments and make sure all CI checks are green. Refer to our guide to troubleshoot common CI failures.

@YanaXu
Copy link
Contributor

YanaXu commented Jul 14, 2025

Hi @a0x1ab , please check wyunchi-ms's comment.

@a0x1ab a0x1ab changed the title [Resources] Added expand functionality to GetAzureResource and GetAzureResourceGroup [Resources] Added ExpandProperties functionality to GetAzureResourceGroup Jul 19, 2025
a0x1ab added 3 commits July 19, 2025 18:00
Added documentation for the -ExpandProperties parameter and related examples to Get-AzResource and Get-AzResourceGroup help files. Updated parameter type annotations and added missing parameter descriptions to improve clarity.
Updated Test-GetResourceGroupWithCreatedTimeAndChangedTime to use the -ExpandProperties flag when retrieving the resource group. Added a new session record to reflect the updated test behavior.
…mmands.Resources.Test.ScenarioTests.ResourceGroupTests/TestGetResourceGroupWithExpandProperties.json
@a0x1ab a0x1ab self-assigned this Jul 19, 2025
@a0x1ab a0x1ab added this to the Az 14.3.0 (08/05/2025) milestone Jul 19, 2025
Replaced explicit new CancellationToken() with It.IsAny<CancellationToken>() in Moq setups to make the tests less brittle and more flexible. Also updated a test call to FilterResourceGroups to include additional parameters.
@a0x1ab a0x1ab enabled auto-merge (squash) July 20, 2025 06:46
a0x1ab added 2 commits July 20, 2025 21:35
Corrected the tag filter logic in FilterResourceGroups to use PSTagValuePair and improved formatting. Updated unit tests to use explicit CancellationToken instances instead of It.IsAny<CancellationToken>() for GetWithHttpMessagesAsync setups.
@YanaXu YanaXu self-assigned this Jul 21, 2025
@a0x1ab a0x1ab requested review from YanaXu and wyunchi-ms July 21, 2025 02:52
@a0x1ab a0x1ab merged commit 92febbd into Azure:main Jul 21, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants