Skip to content

[Core] raw githubusercontent urls are updated to refer azcli blob to restrict external system access#33240

Open
msarfraz wants to merge 8 commits intoAzure:devfrom
msarfraz:network-isolation
Open

[Core] raw githubusercontent urls are updated to refer azcli blob to restrict external system access#33240
msarfraz wants to merge 8 commits intoAzure:devfrom
msarfraz:network-isolation

Conversation

@msarfraz
Copy link
Copy Markdown
Contributor

@msarfraz msarfraz commented Apr 22, 2026

Related command

Description
This PR removes the dependency on GitHub (raw.githubusercontent.com) VM image aliases, replacing it with Azure Blob Storage (azcliprod.blob.core.windows.net). This change enables Azure CLI to work properly in network isolated environments where GitHub access is blocked.

In addition, new validation added in CI pipeline to flag if any raw.githubusercontent.com URL is used in the code.

Background
In enterprise environments with strict network isolation policies, access to raw.githubusercontent.com is not allowed.

Changes

VM Image Alias Migration
Before:
https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-compute/quickstart-templates/aliases.json
After:
https://azcliprod.blob.core.windows.net/cli/vm/aliases_master.json

Release pipeline task:

set -e
 
 # Define files to sync: "github_url|blob_name"
 declare -a FILES=(
   "https://raw.githubusercontent.com/Azure/azure-cli/release/src/azure-cli/setup.py|azure-cli/setup.py"
   "https://raw.githubusercontent.com/Azure/azure-cli/release/src/azure-cli-core/setup.py|azure-cli-core/setup.py"
   "https://raw.githubusercontent.com/Azure/azure-cli/release/src/azure-cli-telemetry/setup.py|azure-cli-telemetry/setup.py"
   "https://raw.githubusercontent.com/Azure/azure-cli/release/src/azure-cli-testsdk/setup.py|azure-cli-testsdk/setup.py"
   "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/arm-compute/quickstart-templates/aliases.json|vm/aliases.json"
   "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-compute/quickstart-templates/aliases.json|vm/aliases_master.json"
 )
 
 TEMP_FILE="/tmp/download_temp"
 FAILED=0
 
 for item in "${FILES[@]}"; do
   # Split by '|'
   GITHUB_URL="${item%|*}"
   BLOB_NAME="${item#*|}"
   
   echo "============================================"
   echo "Syncing: ${BLOB_NAME}"
   echo "From: ${GITHUB_URL}"
   echo "============================================"
   
   # Download from GitHub
   if curl -sL -o "$TEMP_FILE" "$GITHUB_URL"; then
     # Upload to AME Storage
     az storage blob upload \
       --account-name azcliprod \
       --container-name cli \
       --name "$BLOB_NAME" \
       --file "$TEMP_FILE" \
       --overwrite \
       --auth-mode login
     
     echo "✓ Successfully synced: ${BLOB_NAME}"
   else
     echo "✗ Failed to download: ${GITHUB_URL}"
     FAILED=1
   fi
   
   rm -f "$TEMP_FILE"
   echo ""
 done
 
 if [ $FAILED -eq 1 ]; then
   echo "Some files failed to sync!"
   exit 1
 fi
 
 echo "============================================"
 echo "All files synced successfully!"
 echo "============================================"

Testing Guide

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change
[Component Name 2] az command b: Add some customer-facing feature


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

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

azure-client-tools-bot-prd Bot commented Apr 22, 2026

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

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

Hi @msarfraz,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

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

azure-client-tools-bot-prd Bot commented Apr 22, 2026

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 22, 2026

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

@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>

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 aims to remove Azure CLI’s dependency on raw.githubusercontent.com for VM image aliases by switching to an Azure Blob Storage URL (azcliprod.blob.core.windows.net), and adds a CI validation to prevent reintroducing the forbidden URL.

Changes:

  • Update test recordings to use the Azure Blob URL for VM image aliases.
  • Add a CI script to fail PRs that introduce the forbidden raw.githubusercontent.com/.../aliases.json URL in new diff lines.
  • Wire the new CI check into azure-pipelines.yml.

Reviewed changes

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

Show a summary per file
File Description
src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_delete_dependent_resources.yaml Updates recorded request URL for aliases.json from GitHub to Azure Blob.
src/azure-cli/azure/cli/command_modules/cloud/tests/latest/recordings/test_cloud_scenario.yaml Updates recorded cloud metadata response to use Azure Blob for vmImageAliasDoc.
src/azure-cli-core/azure/cli/core/cloud.py Touches vm_image_alias_doc for Azure Bleu cloud (currently still raw GitHub).
scripts/ci/check_aliases_source_url.py Introduces a new CI guard script for forbidden aliases URL usage.
azure-pipelines.yml Runs the new CI guard script during the linter job.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/ci/check_aliases_source_url.py Outdated
Comment thread src/azure-cli-core/azure/cli/core/cloud.py Outdated
Comment thread scripts/ci/check_aliases_source_url.py Outdated
Comment thread scripts/ci/check_aliases_source_url.py Outdated


FORBIDDEN_URL_PATTERN = re.compile(
r"https://raw\.githubusercontent\.com/Azure/azure-rest-api-specs/[A-Za-z0-9._/-]+/arm-compute/quickstart-templates/aliases\.json"
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.

The regex only matches the exact azure-rest-api-specs/.../aliases.json path. If someone introduces a different raw.githubusercontent.com URL for other files, this check won't catch it. The PR's stated goal is to block GitHub URLs in network-isolated environments, so the pattern should be broader —
e.g., simply matching https://raw.githubusercontent.com/.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The regex is updated to match base URL "https://raw.githubusercontent.com" in the code. The documentation, tests, scripts and recordings directories are excluded from validation to avoid false positives

@yonzhan yonzhan assigned msarfraz and unassigned evelyn-ys and jiasli Apr 22, 2026
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 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread azure-pipelines.yml
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 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread azure-pipelines.yml Outdated
Comment thread scripts/ci/validate_external_source_urls.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@msarfraz msarfraz changed the title [Core] githubusercontent urls are updated to refer azcli blob for VM image aliases [Core] raw githubusercontent urls are updated to refer azcli blob to restrict external system access Apr 24, 2026
@msarfraz msarfraz requested a review from Copilot April 24, 2026 07:48
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 5 out of 5 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +92 to +93
parser = argparse.ArgumentParser(description="Check diff for forbidden raw github URL usage.")
parser.add_argument("--src", default="HEAD", help="Source ref/commit for git diff.")
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

In this user-facing argparse description, “github” should be capitalized as “GitHub” to match common project wording and other strings in this file.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Comment on lines +109 to +114
print("No forbidden external github URL found in added lines.")
return 0

print("Found forbidden external github URL in this change:", file=sys.stderr)
for file_path, content in violations:
print(f" - {file_path}: {content}", file=sys.stderr)
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

The log message uses “github” in lowercase; please use “GitHub” for consistency and clarity in CI output.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Comment thread azure-pipelines.yml Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

6 participants