Skip to content

{Cloud} az cloud register/update: Support --endpoint-microsoft-graph-resource-id and --skip-endpoint-discovery#31651

Merged
evelyn-ys merged 3 commits intoAzure:devfrom
evelyn-ys:cloud_register_skip_auto_discovery
Jun 18, 2025
Merged

{Cloud} az cloud register/update: Support --endpoint-microsoft-graph-resource-id and --skip-endpoint-discovery#31651
evelyn-ys merged 3 commits intoAzure:devfrom
evelyn-ys:cloud_register_skip_auto_discovery

Conversation

@evelyn-ys
Copy link
Copy Markdown
Member

Related command

az cloud register/update

Description

This PR does two things:

Testing Guide

# cloud register with a fake resource manager endpoint which can't do cloud endpoints' auto discovery
> az cloud register --name testcloud --endpoint-resource-manager https://foo.management.azure.com --endpoint-active-directory https://foo.login.microsoftonline.com --endpoint-active-directory-resource-id https://foo.management.core.windows.net
Unable to get endpoints from the cloud.
Please ensure you have network connection. Error detail: HTTPSConnectionPool(host='foo.management.azure.com', port=443): Max retries exceeded with url: /metadata/endpoints?api-version=2022-09-01 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000001C62AD0C730>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))

# cloud register with a fake resource manager endpoint and skip the endpoint discovery
> az cloud register --name testcloud --endpoint-resource-manager https://foo.management.azure.com --endpoint-active-directory https://foo.login.microsoftonline.com --endpoint-active-directory-resource-id https://foo.management.core.windows.net --skip-endpoint-discovery

# show the registered cloud
> az cloud show --name testcloud
{
  "endpoints": {
    "activeDirectory": "https://foo.login.microsoftonline.com",
    "activeDirectoryDataLakeResourceId": null,
    "activeDirectoryGraphResourceId": null,
    "activeDirectoryResourceId": "https://foo.management.core.windows.net",
    "appInsightsResourceId": null,
    "appInsightsTelemetryChannelResourceId": null,
    "attestationResourceId": null,
    "azmirrorStorageAccountResourceId": null,
    "batchResourceId": null,
    "gallery": null,
    "logAnalyticsResourceId": null,
    "management": "https://foo.management.azure.com",
    "mediaResourceId": null,
    "microsoftGraphResourceId": null,
    "ossrdbmsResourceId": null,
    "portal": null,
    "resourceManager": "https://foo.management.azure.com",
    "sqlManagement": null,
    "synapseAnalyticsResourceId": null,
    "vmImageAliasDoc": null
  },
  "isActive": false,
  "name": "testcloud",
  "profile": "latest",
  "suffixes": {
    "acrLoginServerEndpoint": null,
    "attestationEndpoint": null,
    "azureDatalakeAnalyticsCatalogAndJobEndpoint": null,
    "azureDatalakeStoreFileSystemEndpoint": null,
    "keyvaultDns": null,
    "mariadbServerEndpoint": null,
    "mhsmDns": null,
    "mysqlServerEndpoint": null,
    "postgresqlServerEndpoint": null,
    "sqlServerHostname": null,
    "storageEndpoint": null,
    "storageSyncEndpoint": null,
    "synapseAnalyticsEndpoint": null
  }
}

History Notes

[Cloud] az cloud register/update: Add --endpoint-microsoft-graph-resource-id to support configuring Microsoft Graph endpoint
[Cloud] az cloud register/update: Add --skip-endpoint-discovery to allow skipping cloud endpoints' auto discovery


This checklist is used to make sure that common guidelines for a pull request are followed.

Copilot AI review requested due to automatic review settings June 13, 2025 05:28
@evelyn-ys evelyn-ys requested a review from jiasli as a code owner June 13, 2025 05:28
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Jun 13, 2025

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.9
️✔️acs
️✔️latest
️✔️3.12
️✔️3.9
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.9
️✔️ams
️✔️latest
️✔️3.12
️✔️3.9
️✔️apim
️✔️latest
️✔️3.12
️✔️3.9
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.9
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️aro
️✔️latest
️✔️3.12
️✔️3.9
️✔️backup
️✔️latest
️✔️3.12
️✔️3.9
️✔️batch
️✔️latest
️✔️3.12
️✔️3.9
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.9
️✔️billing
️✔️latest
️✔️3.12
️✔️3.9
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.9
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.9
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.9
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.9
️✔️config
️✔️latest
️✔️3.12
️✔️3.9
️✔️configure
️✔️latest
️✔️3.12
️✔️3.9
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.9
️✔️container
️✔️latest
️✔️3.12
️✔️3.9
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.9
️✔️core
️✔️latest
️✔️3.12
️✔️3.9
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.9
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.9
️✔️dls
️✔️latest
️✔️3.12
️✔️3.9
️✔️dms
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.9
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.9
️✔️find
️✔️latest
️✔️3.12
️✔️3.9
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.9
️✔️identity
️✔️latest
️✔️3.12
️✔️3.9
️✔️iot
️✔️latest
️✔️3.12
️✔️3.9
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.9
️✔️lab
️✔️latest
️✔️3.12
️✔️3.9
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️maps
️✔️latest
️✔️3.12
️✔️3.9
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.9
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.9
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.9
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.9
️✔️network
️✔️latest
️✔️3.12
️✔️3.9
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.9
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.9
️✔️profile
️✔️latest
️✔️3.12
️✔️3.9
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.9
️✔️redis
️✔️latest
️✔️3.12
️✔️3.9
️✔️relay
️✔️latest
️✔️3.12
️✔️3.9
️✔️resource
️✔️latest
️✔️3.12
️✔️3.9
️✔️role
️✔️latest
️✔️3.12
️✔️3.9
️✔️search
️✔️latest
️✔️3.12
️✔️3.9
️✔️security
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.9
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.9
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.9
️✔️sql
️✔️latest
️✔️3.12
️✔️3.9
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.9
️✔️storage
️✔️latest
️✔️3.12
️✔️3.9
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.9
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.9
️✔️util
️✔️latest
️✔️3.12
️✔️3.9
️✔️vm
️✔️latest
️✔️3.12
️✔️3.9

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Jun 13, 2025

⚠️AzureCLI-BreakingChangeTest
⚠️cloud
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd cloud register cmd cloud register added parameter endpoint_microsoft_graph_resource_id
⚠️ 1006 - ParaAdd cloud register cmd cloud register added parameter skip_endpoint_discovery
⚠️ 1006 - ParaAdd cloud update cmd cloud update added parameter endpoint_microsoft_graph_resource_id
⚠️ 1006 - ParaAdd cloud update cmd cloud update added parameter skip_endpoint_discovery

@github-actions
Copy link
Copy Markdown

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Jun 13, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

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 PR enhances the az cloud register and az cloud update commands by adding two new options:

  • --endpoint-microsoft-graph-resource-id to configure the Microsoft Graph endpoint
  • --skip-endpoint-discovery to bypass automatic endpoint discovery when metadata fetches fail

Reviewed Changes

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

File Description
test_cloud.py Added a scenario to verify that --skip-endpoint-discovery skips discovery and preserves resourceManager.
custom.py Updated _build_cloud, register_cloud, and modify_cloud to accept the new flags and wire them through.
init.py Exposed the new CLI arguments skip_endpoint_discovery and endpoint_microsoft_graph_resource_id.

Comments suppressed due to low confidence (1)

src/azure-cli/azure/cli/command_modules/cloud/tests/latest/test_cloud.py:105

  • Add a test case for the new --endpoint-microsoft-graph-resource-id flag (e.g., update with --endpoint-microsoft-graph-resource-id https://graph.example.com and assert that endpoints.microsoft_graph_resource_id is set).
# Skip cloud discovery



def _build_cloud(cli_ctx, cloud_name, cloud_config=None, cloud_args=None):
def _build_cloud(cli_ctx, cloud_name, skip_endpoint_discovery=False, cloud_config=None, cloud_args=None):
Copy link

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

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

[nitpick] The skip-discovery branch duplicates parts of the cloud construction logic. Consider refactoring so common setup (e.g., setting c.name, c.profile, and applying cloud_args) is shared, reducing code duplication.

Copilot uses AI. Check for mistakes.
@yonzhan yonzhan assigned evelyn-ys and unassigned ReaNAiveD Jun 13, 2025
@yonzhan yonzhan removed the Portal az portal label Jun 13, 2025
c = _build_cloud(cmd.cli_ctx, cloud_name, cloud_config=cloud_config,
cloud_args=locals())
c = _build_cloud(cmd.cli_ctx, cloud_name, skip_endpoint_discovery=skip_endpoint_discovery,
cloud_config=cloud_config, cloud_args=locals())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Using locals() is very hacky and unpredictable. It may end up with unwanted variables being recorded in the cloud.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it's an old implementation which is unrelated with my changes. So I didn't modify it

Copy link
Copy Markdown
Member

@jiasli jiasli Jun 13, 2025

Choose a reason for hiding this comment

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

I know. Technical debt, not necessary to address right now.

@jiasli
Copy link
Copy Markdown
Member

jiasli commented Jun 13, 2025

Nitpicking: This PR contains 2 independent features. Creating a PR for each feature is a better practice.

@evelyn-ys
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@evelyn-ys evelyn-ys merged commit 9b83b33 into Azure:dev Jun 18, 2025
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az cloud register should support configuring Microsoft Graph endpoint

6 participants