Skip to content

Conversation

@Francisco-Gamino
Copy link
Contributor

@Francisco-Gamino Francisco-Gamino commented Jan 7, 2026

Description

This PR fixes issues #29034 where New-AzFunctionApp fails in non-public Azure clouds due to hardcoded endpoint values for storage connection strings. The change ensure full cloud portability across Azure Public and custom cloud environments.

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 January 7, 2026 21:30
@azure-client-tools-bot-prd
Copy link

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

@Francisco-Gamino
Copy link
Contributor Author

@isra-fel
Copy link
Member

isra-fel commented Jan 7, 2026

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
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 addresses cloud portability issues in Az.Functions by replacing hardcoded endpoint values with dynamic endpoint resolution for storage connection strings and Application Insights. The changes ensure that New-AzFunctionApp can work correctly across Azure Public Cloud and custom/sovereign Azure cloud environments.

Key Changes

  • Modified GetEndpointSuffix function to use StorageEndpointSuffix property from Azure context instead of hardcoded switch statement
  • Updated Application Insights endpoint construction in WhatIf scenario to dynamically retrieve endpoint from Azure context

Reviewed changes

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

File Description
src/Functions/Functions.Autorest/custom/HelperFunctions.ps1 Refactored GetEndpointSuffix to use StorageEndpointSuffix property from Azure environment context, replacing hardcoded endpoint mappings for different cloud environments
src/Functions/Functions.Autorest/custom/New-AzFunctionApp.ps1 Updated WhatIf scenario to dynamically construct Application Insights endpoints using AzureApplicationInsightsEndpointResourceId from Azure environment context instead of hardcoded "applicationinsights.azure.com" domain

@Francisco-Gamino
Copy link
Contributor Author

@wyunchi-ms - Would it be possible to include this fix in the Az 15.2.0 release? Thank you.

@Francisco-Gamino Francisco-Gamino changed the title [Az.Functions] Fix cloud portability by using dynamic endpoints for storage and Application Insights [Az.Functions] Fix cloud portability by using dynamic endpoints for storage Jan 7, 2026
@isra-fel
Copy link
Member

isra-fel commented Jan 7, 2026

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Member

@isra-fel isra-fel left a comment

Choose a reason for hiding this comment

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

LGTM but please update the ChangeLog.md file

Copilot AI review requested due to automatic review settings January 8, 2026 00:15
Copy link
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 2 out of 2 changed files in this pull request and generated no new comments.

@Francisco-Gamino
Copy link
Contributor Author

@isra-fel - Thank you for the review. The change log has been updated.

@isra-fel isra-fel changed the base branch from main to release-2026-01-13 January 8, 2026 00:29
@isra-fel
Copy link
Member

isra-fel commented Jan 8, 2026

LGTM

@isra-fel
Copy link
Member

isra-fel commented Jan 8, 2026

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@wyunchi-ms
Copy link
Contributor

Hi @Francisco-Gamino , the code freeze date is Jan 6, so we cannot accept this PR in this release. I will re-target this to main branch. Let's release it in the next release.

@wyunchi-ms wyunchi-ms changed the base branch from release-2026-01-13 to main January 12, 2026 03:28
public X509Certificate2 GetCert() { return _cert; }

static RSAParameters RsaParamsFromPem(string path, string password) // CodeQL [SM02205] BouncyCastle is the only API available because we need to be at netstandard2.0
static RSAParameters RsaParamsFromPem(string path, string password) //CodeQL [SM02205] BouncyCastle is the only API available because we need to be at netstandard2.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert the change here.

-->
## Upcoming Release

* Fix cloud portability by using dynamic endpoints for storage [#29034]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Fix cloud portability by using dynamic endpoints for storage [#29034]
* Fixed cloud portability by using dynamic endpoints for storage [#29034]

@github-actions
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.

Copilot AI review requested due to automatic review settings January 16, 2026 18:34
@Francisco-Gamino Francisco-Gamino force-pushed the functions-fix-connectionstring-endpointsuffix branch from 092b548 to 69366db Compare January 16, 2026 18:34
@isra-fel
Copy link
Member

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
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 2 out of 2 changed files in this pull request and generated 2 comments.

-->
## Upcoming Release

* Fixed cloud portability by using dynamic endpoints for storage [#29034]
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The changelog entry could be more descriptive for users. Consider expanding it to explain the impact and what specific issue was fixed. For example: "Fixed 'New-AzFunctionApp' cmdlet to work in non-public Azure clouds by dynamically retrieving storage endpoints instead of using hardcoded values. This enables full cloud portability across Azure Public, Government, China, and custom cloud environments."

Copilot generated this review using guidance from repository custom instructions.
Comment on lines +163 to 164
$storageEndpointSuffix = (Get-AzContext).Environment.StorageEndpointSuffix

Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The function could throw a null reference exception if Get-AzContext returns null. Consider adding error handling to check if the context exists before accessing its properties. For example: '$context = Get-AzContext; if ($null -eq $context) { return '' }; $storageEndpointSuffix = $context.Environment.StorageEndpointSuffix'

Suggested change
$storageEndpointSuffix = (Get-AzContext).Environment.StorageEndpointSuffix
$context = Get-AzContext
if ($null -eq $context -or $null -eq $context.Environment)
{
return ''
}
$storageEndpointSuffix = $context.Environment.StorageEndpointSuffix

Copilot uses AI. Check for mistakes.
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.

4 participants