Skip to content

[Storage] Support Storage Account saspolicy new properties SasExpirationAction #27908

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 4 commits into from
Jun 12, 2025

Conversation

blueww
Copy link
Member

@blueww blueww commented Jun 10, 2025

Description

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

@Copilot Copilot AI review requested due to automatic review settings June 10, 2025 07:38
Copy link

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

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

Adds support for the new -SasExpirationAction property on storage account cmdlets, allowing users to specify how violations of SAS expiration policies are handled, and updates documentation, tests, and changelog accordingly.

  • Introduce SasExpirationAction parameter (Log or Block) in New/Set-AzStorageAccount cmdlets
  • Handle defaulting, validation, and policy construction logic in C# implementation
  • Update help markdown, tests, and changelog for the new parameter

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Storage/Storage.Management/StorageAccount/SetAzureStorageAccount.cs Add SasExpirationAction parameter and integrate into update logic
src/Storage/Storage.Management/StorageAccount/NewAzureStorageAccount.cs Add SasExpirationAction parameter and integrate into creation logic
src/Storage/Storage.Management/help/Set-AzStorageAccount.md Add parameter help/details, update examples with action column
src/Storage/Storage.Management/help/New-AzStorageAccount.md Add parameter help/details, update examples with action column
src/Storage/Storage.Management/ChangeLog.md Document upcoming release changes for SasExpirationAction
src/Storage/Storage.Management.Test/ScenarioTests/StorageAccountTests.ps1 Add scenario tests for default and explicit SasExpirationAction
Comments suppressed due to low confidence (6)

src/Storage/Storage.Management/StorageAccount/SetAzureStorageAccount.cs:473

  • Consider adding a [PSDefaultValue(Help = "Log", Value = StorageModels.ExpirationAction.Log)] attribute to match the default behavior and help callers discover the default.
[Parameter(Mandatory = false, HelpMessage = "The action to be performed when SasExpirationPeriod is violated.")]

src/Storage/Storage.Management/help/Set-AzStorageAccount.md:1146

  • Update the 'Default value' to 'Log' (or the appropriate action) to reflect the actual default applied by the cmdlet.
Default value: None

src/Storage/Storage.Management/help/New-AzStorageAccount.md:1212

  • Change the default value from 'None' to 'Log' to accurately document the cmdlet's behavior.
Default value: None

src/Storage/Storage.Management/help/Set-AzStorageAccount.md:288

  • Remove the extra space before the comma in 'SasExpirationAction ,' for proper punctuation.
This command updates a Storage account with KeyExpirationPeriod and SasExpirationPeriod with SasExpirationAction , then show the updated account related properties.

src/Storage/Storage.Management/ChangeLog.md:21

  • [nitpick] Rephrase this entry for clarity and correct grammar (e.g., 'Support SasExpirationAction (Log|Block) with SasExpirationPeriod').
* Supported set SasExpirationAction as Log or Block, together with SasExpirationPeriod

src/Storage/Storage.Management.Test/ScenarioTests/StorageAccountTests.ps1:1697

  • Add a negative test case to verify that specifying -SasExpirationAction without -SasExpirationPeriod throws the expected exception.
function Test-AzureStorageAccountKeySASPolicy

@blueww
Copy link
Member Author

blueww commented Jun 10, 2025

@vidai-msft

Would you please help to look at the only test case failure?
https://dev.azure.com/azclitools/public/_build/results?buildId=249688&view=logs&jobId=e44bd064-d8d9-5feb-6343-09b8c49ab1a8&j=e44bd064-d8d9-5feb-6343-09b8c49ab1a8&t=c414cfc4-3e2d-5217-f499-961bb73fce42

The failed test case "Microsoft.Azure.Commands.Management.Storage.Test.ScenarioTests.StorageAccountTests.TestNewSetAzureStorageAccountTLSveresionBlobPublicAccess" is no changed in this PR, and the test only fail on MacOS. I also can't repro this failure on my local machine (win11).

@blueww
Copy link
Member Author

blueww commented Jun 10, 2025

/azp run

Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@vidai-msft
Copy link
Contributor

The function Retry-IfException looks like has a subtle issue. It relies on the global variable $Error which could be set from outside of the function scope. However, I did not see it was reset at the beginning of the function call.

@blueww
Copy link
Member Author

blueww commented Jun 11, 2025

Hi @vidai-msft,

Thanks for looking at the test failure!

As the test pass after rerun, would you like to review and merge this PR if not other issue?

Copy link
Contributor

@vidai-msft vidai-msft left a comment

Choose a reason for hiding this comment

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

LGTM

@vidai-msft vidai-msft merged commit ffedcad into Azure:main Jun 12, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants