Skip to content

Migrate Az.Functions from AutoRest PowerShell v3 to v4#29321

Open
Francisco-Gamino wants to merge 9 commits intoAzure:mainfrom
Francisco-Gamino:functions/autorest-v4-upgrade-clean
Open

Migrate Az.Functions from AutoRest PowerShell v3 to v4#29321
Francisco-Gamino wants to merge 9 commits intoAzure:mainfrom
Francisco-Gamino:functions/autorest-v4-upgrade-clean

Conversation

@Francisco-Gamino
Copy link
Copy Markdown
Contributor

Description

This PR migrates the Az.Functions module from AutoRest PowerShell v3 to v4, replacing #29111 with additional bug fixes, updated test recordings, and refreshed function app stacks.

Breaking Changes

Identity Parameter Changes

  • -IdentityType -> -EnableSystemAssignedIdentity: The enum parameter accepting values like SystemAssigned, UserAssigned, SystemAssigned,UserAssigned has been replaced with a switch/boolean parameter. Use -EnableSystemAssignedIdentity or -EnableSystemAssignedIdentity:$true to enable system-assigned identity.
  • -IdentityID -> -UserAssignedIdentity: Parameter renamed. Accepts the same String[] of user-assigned identity resource IDs.

Output Type Changes

  • Enum properties now return strings: Properties like IdentityType now return string values (e.g., "SystemAssigned, UserAssigned") instead of enum objects.
  • Array properties now return List<T>: Collections like IdentityUserAssignedIdentity return List<T> instead of arrays.
  • User-assigned identity access: Access user-assigned identities via $app.IdentityUserAssignedIdentity.AdditionalProperties instead of $app.UserAssignedIdentity.

Bug Fixes

  • Fixed identity parameter handling to support all combinations (SystemAssigned-only, UserAssigned-only, combined)
  • Fixed AppSettings type to use List[INameValuePair] instead of List[Object]
  • Added guards for Flex Consumption and Container App SKUs in Update-AzFunctionApp
  • Fixed empty array validation for -UserAssignedIdentity parameter

Test Changes

  • Added new test: New-AzFunctionApp: Create function app with system-assigned and user-assigned identity combined
  • Added new test: Update-AzFunctionApp: Validate Flex Consumption app cannot be updated
  • Updated existing tests to use new identity parameter names and assertion patterns
  • All 64 tests pass (18 skipped)
  • Recordings sanitized (no secrets)

Stack Updates

  • Updated functionAppStacks.json with Node 24, Python 3.14, Java 25

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 AI review requested due to automatic review settings March 26, 2026 05:32
@azure-client-tools-bot-prd
Copy link
Copy Markdown

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

@NoriZC
Copy link
Copy Markdown
Contributor

NoriZC commented Mar 26, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Copy Markdown
Contributor

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 pull request migrates the Az.Functions module from AutoRest PowerShell v3 to v4, updating generated/custom cmdlets, help/docs, and test assets to align with the new model/types and revised identity parameter behavior.

Changes:

  • Migrates cmdlets/models to AutoRest PowerShell v4 (type namespace changes, new partial model support classes).
  • Updates New-AzFunctionApp / Update-AzFunctionApp identity parameters and adds SKU guards in Update-AzFunctionApp.
  • Refreshes help/docs/examples, test scripts, and stack definitions (functionAppStacks.json) with new runtimes/SKU metadata.

Reviewed changes

Copilot reviewed 65 out of 75 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/Functions/Functions/help/Update-AzFunctionAppSetting.md Help text updates for v4 model types and parameter descriptions.
src/Functions/Functions/help/Update-AzFunctionAppPlan.md Help text updates for v4 model types and parameter descriptions.
src/Functions/Functions/help/Update-AzFunctionApp.md Updates help to reflect new identity parameters and v4 model types.
src/Functions/Functions/help/Stop-AzFunctionApp.md Updates help descriptions and v4 model types.
src/Functions/Functions/help/Start-AzFunctionApp.md Updates help descriptions and v4 model types.
src/Functions/Functions/help/Restart-AzFunctionApp.md Updates help descriptions and v4 model types.
src/Functions/Functions/help/Remove-AzFunctionAppSetting.md Updates help descriptions and v4 model types.
src/Functions/Functions/help/Remove-AzFunctionAppPlan.md Updates help descriptions and v4 model types.
src/Functions/Functions/help/Remove-AzFunctionApp.md Updates help descriptions and v4 model types.
src/Functions/Functions/help/New-AzFunctionAppPlan.md Updates help with DefaultProfile description and v4 output type.
src/Functions/Functions/help/New-AzFunctionApp.md Updates help for new identity parameters and v4 model types.
src/Functions/Functions/help/Get-AzFunctionAppSetting.md Updates help descriptions and v4 model types.
src/Functions/Functions/help/Get-AzFunctionAppPlan.md Updates help output type to v4 model type.
src/Functions/Functions/help/Get-AzFunctionAppAvailableLocation.md Updates help output type to v4 model type.
src/Functions/Functions/help/Get-AzFunctionApp.md Updates help output type to v4 model type.
src/Functions/Functions/Properties/AssemblyInfo.cs Updates Functions assembly version metadata.
src/Functions/Functions/ChangeLog.md Updates Upcoming Release notes to describe v3→v4 migration and breaking changes.
src/Functions/Functions/Az.Functions.psd1 Updates module manifest metadata/version and release notes content.
src/Functions/Functions.sln Updates solution project GUID reference for regenerated project.
src/Functions/Functions.Autorest/test/utils.ps1 Expands test environment setup, including Flex Consumption guard test setup.
src/Functions/Functions.Autorest/test/env.json Refreshes recorded test environment values and adds new fields for new tests.
src/Functions/Functions.Autorest/test/New-Update-Remove-AzFunctionApp.Tests.ps1 Updates tests for new identity parameters and adds new identity/guard scenarios.
src/Functions/Functions.Autorest/test/New-AzFunctionApp.Tests.ps1 Updates tests for new identity parameters and adds combined identity coverage.
src/Functions/Functions.Autorest/test/New-AzFunctionApp.FlexConsumption.Tests.ps1 Updates Flex tests to new identity parameters.
src/Functions/Functions.Autorest/generate-info.json Updates generation identifier for v4 regeneration.
src/Functions/Functions.Autorest/examples/Update-AzFunctionApp.md Updates examples to new identity parameter usage.
src/Functions/Functions.Autorest/docs/Update-AzFunctionAppSetting.md Updates docs parameter descriptions and v4 model types.
src/Functions/Functions.Autorest/docs/Update-AzFunctionAppPlan.md Updates docs parameter descriptions and v4 model types.
src/Functions/Functions.Autorest/docs/Update-AzFunctionApp.md Updates docs for new identity parameters and v4 model types.
src/Functions/Functions.Autorest/docs/Stop-AzFunctionApp.md Updates docs parameter descriptions and v4 model types.
src/Functions/Functions.Autorest/docs/Start-AzFunctionApp.md Updates docs parameter descriptions and v4 model types.
src/Functions/Functions.Autorest/docs/Restart-AzFunctionApp.md Updates docs parameter descriptions and v4 model types.
src/Functions/Functions.Autorest/docs/Remove-AzFunctionAppSetting.md Updates docs parameter descriptions and v4 model types.
src/Functions/Functions.Autorest/docs/Remove-AzFunctionAppPlan.md Updates docs parameter descriptions and v4 model types.
src/Functions/Functions.Autorest/docs/Remove-AzFunctionApp.md Updates docs parameter descriptions and v4 model types.
src/Functions/Functions.Autorest/docs/New-AzFunctionAppPlan.md Updates docs parameter descriptions and v4 model types.
src/Functions/Functions.Autorest/docs/New-AzFunctionApp.md Updates docs for new identity parameters and v4 model types.
src/Functions/Functions.Autorest/docs/Get-AzFunctionAppSetting.md Updates docs parameter descriptions and v4 model types.
src/Functions/Functions.Autorest/docs/Get-AzFunctionAppPlan.md Updates docs output type to v4 model type.
src/Functions/Functions.Autorest/docs/Get-AzFunctionAppAvailableLocation.md Updates docs output type to v4 model type.
src/Functions/Functions.Autorest/docs/Get-AzFunctionApp.md Updates docs output type to v4 model type.
src/Functions/Functions.Autorest/docs/Az.Functions.md Updates module GUID metadata in docs.
src/Functions/Functions.Autorest/custom/api/Support/Site.cs Adds v4 partial model support for custom properties on Site.
src/Functions/Functions.Autorest/custom/api/Support/AppServicePlan.cs Adds v4 partial model support for custom properties on AppServicePlan.
src/Functions/Functions.Autorest/custom/Update-AzFunctionAppSetting.ps1 Updates output type and parameter metadata for v4 models.
src/Functions/Functions.Autorest/custom/Update-AzFunctionAppPlan.ps1 Updates v4 model types and plan construction type.
src/Functions/Functions.Autorest/custom/Update-AzFunctionApp.ps1 Implements new identity parameters, SKU guards, and v4 model usage.
src/Functions/Functions.Autorest/custom/Stop-AzFunctionApp.ps1 Updates parameter metadata for v4 model input.
src/Functions/Functions.Autorest/custom/Start-AzFunctionApp.ps1 Updates parameter metadata for v4 model input.
src/Functions/Functions.Autorest/custom/Restart-AzFunctionApp.ps1 Updates parameter metadata for v4 model input.
src/Functions/Functions.Autorest/custom/Remove-AzFunctionAppSetting.ps1 Updates output type and parameter metadata for v4 models.
src/Functions/Functions.Autorest/custom/Remove-AzFunctionAppPlan.ps1 Updates parameter metadata for v4 model input.
src/Functions/Functions.Autorest/custom/Remove-AzFunctionApp.ps1 Updates parameter metadata for v4 model input.
src/Functions/Functions.Autorest/custom/New-AzFunctionAppPlan.ps1 Updates v4 model types and plan construction type.
src/Functions/Functions.Autorest/custom/New-AzFunctionApp.ps1 Implements new identity parameters and v4 model usage.
src/Functions/Functions.Autorest/custom/HelperFunctions.ps1 Updates model type instantiations, endpoint suffix logic, and name availability call.
src/Functions/Functions.Autorest/custom/Get-AzFunctionAppSetting.ps1 Updates output type and parameter metadata for v4 models.
src/Functions/Functions.Autorest/custom/Get-AzFunctionAppPlan.ps1 Updates output type for v4 models.
src/Functions/Functions.Autorest/custom/Get-AzFunctionAppAvailableLocation.ps1 Updates output type for v4 models.
src/Functions/Functions.Autorest/custom/Get-AzFunctionApp.ps1 Updates output type for v4 models.
src/Functions/Functions.Autorest/custom/FunctionsStack/functionAppStacks.json Refreshes stack definitions (Node 24, Python 3.14, Java 25) and FC1 SKU metadata.
src/Functions/Functions.Autorest/custom/Functions.types.ps1xml Updates type names to v4 model namespaces for formatting/aliases.
src/Functions/Functions.Autorest/custom/Functions.format.ps1xml Updates format view type names to v4 model namespaces.
src/Functions/Functions.Autorest/README.md Switches AutoRest PowerShell extension to 4.x and updates directives.
src/Functions/Functions.Autorest/Properties/AssemblyInfo.cs Updates AutoRest assembly version metadata.
Comments suppressed due to low confidence (1)

src/Functions/Functions/ChangeLog.md:33

  • The changelog jumps from ## Upcoming Release directly to ## Version 4.3.0, and no longer includes a ## Version 4.3.1 section. If 4.3.1 was previously released, removing that entry rewrites release history and also conflicts with the prior 4.3.1 module version.

@Francisco-Gamino Francisco-Gamino force-pushed the functions/autorest-v4-upgrade-clean branch from d3ce2b5 to b727b8e Compare March 26, 2026 08:59
@NoriZC
Copy link
Copy Markdown
Contributor

NoriZC commented Mar 26, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Breaking changes:
- Replaced -IdentityType parameter with -EnableSystemAssignedIdentity
  (Boolean/SwitchParameter) in New-AzFunctionApp and Update-AzFunctionApp
- Replaced -IdentityID parameter with -UserAssignedIdentity (String
  array of ARM resource IDs) in New-AzFunctionApp and Update-AzFunctionApp
- New-AzFunctionApp and Update-AzFunctionApp now support combining
  SystemAssigned and UserAssigned identities in a single call
- Output type property changes: enum types converted to strings,
  arrays converted to Lists (see BreakingChangeIssues.csv)

Bug fixes:
- Fix parameter set conflict between Create and CreateExpanded when
  passing identity params to internal cmdlet
- Fix AppSetting list type (List[Object] to List[INameValuePair])
- Fix error messages to reference new parameter names
- Fix variable typo (siteCofig to siteConfig)
- Add SKU validation guards for Flex Consumption and Container App plans

Tests:
- Added combined SystemAssigned+UserAssigned identity tests for
  New-AzFunctionApp and Update-AzFunctionApp
- Added Update-AzFunctionApp error guard test for Flex Consumption apps
- Updated test assertions for new parameter names and ErrorIds
- Removed 9 auto-generated template test stubs
- All 64 tests pass in both record and playback modes

Other:
- Updated functionAppStacks.json (adds Node.js 24, Python 3.14, Java 25)
- Added HelpMessage attributes for InputObject, DefaultProfile, and
  ResourceGroupName across all custom cmdlets
- Added comment on StorageAccounts_Update remove-operation directive
- Fix identity parameter detection in Update-AzFunctionApp to use
  PSBoundParameters.ContainsKey instead of truthiness check, correctly
  handling -UserAssignedIdentity @() empty array case
- Remove duplicate -Name parameter in ValidateFunctionAppNameAvailability
  to prevent runtime binding error (Name already in PSBoundParameters)
- Add [Parameter(DontShow)] and [SwitchParameter] type to  param
  in New-AzFunctionApp to hide it from public help
- Update help example to use -EnableSystemAssignedIdentity:False instead
  of 0 for Boolean parameter clarity
- Restore module/assembly versions to 4.3.1 to match upstream/main
- Remove obsolete custom/Api20231201/ files (superseded by custom/api/Support/)
…igration

- Fix stale v3 namespace reference: Models.Api20190401.BlobContainer to
  Models.BlobContainer in New-AzFunctionApp WhatIf path
- Re-record all test recordings against live Azure (78 passed, 0 failed)
- Sanitize recordings (secrets replaced with placeholders)
- All tests validated in Live mode (98 passed, 0 failed, 18 skipped)
  including LiveOnly-tagged ACA and Flex Consumption tests
Copilot AI review requested due to automatic review settings March 28, 2026 07:50
@Francisco-Gamino Francisco-Gamino force-pushed the functions/autorest-v4-upgrade-clean branch from b727b8e to 793a58c Compare March 28, 2026 07:50
Copy link
Copy Markdown
Contributor

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

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

Comments suppressed due to low confidence (1)

src/Functions/Functions.Autorest/Properties/AssemblyInfo.cs:33

  • There are multiple trailing blank lines added at the end of the file. Please remove the extra empty lines to keep the generated file clean and minimize noisy diffs.

Comment on lines +16 to +19
# Please note that these tests can run in Playback mode only when executed locally. They fail in the pipeline due to the environment.
# However, they can be used for local deployment in Playback mode.
# Describe 'New-AzFunctionApp - Flex Consumption' {
Describe 'New-AzFunctionApp - Flex Consumption' -Tag 'LiveOnly' {
Describe 'New-AzFunctionApp - Flex Consumption' {
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

The file comment says these Flex Consumption tests "fail in the pipeline" and were previously gated by -Tag 'LiveOnly', but the Describe block no longer has that tag. Either update the comment (if pipeline support was fixed) or restore appropriate tagging/conditional skipping so CI doesn’t start running tests that are known to be environment-dependent.

Copilot uses AI. Check for mistakes.
@NoriZC
Copy link
Copy Markdown
Contributor

NoriZC commented Mar 28, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

…ex test comment

- Fix typo in Update-AzFunctionApp.ps1 comment: 'intenal' -> 'internal',
  'process' -> 'processed'
- Expand acronyms in ChangeLog.md per Azure PS guidelines: ARM (Azure
  Resource Manager), SKU (stock keeping unit)
- Clarify parameter types in ChangeLog: SwitchParameter for New-*, Boolean
  for Update-*
- Update Flex Consumption test comment: removed outdated 'fail in pipeline'
  note since tests now work in all modes including CI playback
@NoriZC
Copy link
Copy Markdown
Contributor

NoriZC commented Mar 28, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

…y v4 migration

- Replace hardcoded GetEndpointSuffix switch with dynamic
  StorageEndpointSuffix from Azure context (originally merged as Azure#29035)
- The v4 migration regenerated from pre-Azure#29035 code, inadvertently
  reverting the cloud portability fix [Azure#29034]
Copilot AI review requested due to automatic review settings March 28, 2026 08:49
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 64 out of 75 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

src/Functions/Functions.Autorest/Properties/AssemblyInfo.cs:35

  • This file now ends with a large block of trailing blank lines. Please remove the extra empty lines to keep the generated assembly metadata clean and reduce diff noise in future regenerations.

- Add null check for Get-AzContext and context.Environment before
  accessing StorageEndpointSuffix, preventing null reference exceptions
  when no Azure session is active
@NoriZC
Copy link
Copy Markdown
Contributor

NoriZC commented Mar 28, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

- Handle combined 'SystemAssigned,UserAssigned' identity type in fallback
  logic using -match instead of exact string comparison
- Fix help example: use -EnableSystemAssignedIdentity \True instead of 1
- Update test assertion for combined identity to use -Match pattern
- Add ChangeLog entry for combined identity fallback fix
Copilot AI review requested due to automatic review settings March 28, 2026 19:30
- Restore [PreviewMessage()] BC announcement attributes to all 14
  custom cmdlet files. These were lost when the v4 migration commit
  overwrote the files with regenerated code from pre-Azure#29139 base.
- Attributes announce breaking changes in Az v16.0.0 (May 2026)
  per the BC announcement PR Azure#29139
@Francisco-Gamino Francisco-Gamino force-pushed the functions/autorest-v4-upgrade-clean branch from 3965c10 to fdcdf80 Compare March 28, 2026 19:36
@NoriZC
Copy link
Copy Markdown
Contributor

NoriZC commented Mar 28, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Copy Markdown
Contributor

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

Copilot reviewed 64 out of 75 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/Functions/Functions.Autorest/Properties/AssemblyInfo.cs:38

  • There are multiple trailing blank lines added at the end of this file. Please remove the extra empty lines to keep generated assembly metadata files clean and minimize unnecessary diffs.

The user identity references will be ARM resource ids in the form:
'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/identities/{identityName}'")]
'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'")]
[ValidateNotNullOrEmpty()]
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

UserAssignedIdentity has [ValidateNotNullOrEmpty()], but the cmdlet also contains custom logic to detect an empty array and throw a terminating error with ErrorId UserAssignedIdentityRequired. With ValidateNotNullOrEmpty, an empty array (-UserAssignedIdentity @()) will fail during parameter binding and bypass the intended ErrorId/message. Consider changing this to [ValidateNotNull()] (and rely on the existing $UserAssignedIdentity.Count -eq 0 check) so callers get the consistent UserAssignedIdentityRequired error.

Suggested change
[ValidateNotNullOrEmpty()]
[ValidateNotNull()]

Copilot uses AI. Check for mistakes.
Comment on lines 654 to 655
Write-Verbose "Validate that the expected expetedErrorId is thrown" -Verbose
$scriptblock | Should -Throw -ErrorId $expectedErrorId
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

Typo in log message: "expetedErrorId" should be "expectedErrorId".

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants