Repository navigation
{AAZ} Added functionality to AAZ MCP Server #32079
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
Changes from 13 commits
5834f6c
bd8fe8f
5586c3f
04aa6cc
ebf8525
478ebbc
1196b77
d0ea80a
9c465ab
087622f
c1cef33
1f797d1
c1f3766
a5c771c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,13 @@ | ||
| FROM mcr.microsoft.com/devcontainers/python:3.12 | ||
|
|
||
| # Copy binaries from the official | ||
| # Copy uv binaries for virtual environment management | ||
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | ||
|
|
||
| # Remove after production | ||
| RUN pip install --no-cache-dir mcp | ||
| # Install git and mcp, create /workspaces-src with correct ownership | ||
| RUN apt-get update && apt-get install -y git \ | ||
| && pip install --no-cache-dir mcp \ | ||
| && mkdir -p /workspaces-src \ | ||
| && chown -R vscode:vscode /workspaces-src | ||
|
|
||
| # Ensure bash is default shell | ||
| SHELL ["/bin/bash", "-c"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,12 @@ | ||
| { | ||
| "name": "Azure CLI Dev Container", | ||
| "build": { | ||
| "dockerfile": "Dockerfile" | ||
| "dockerfile": "Dockerfile", | ||
| "context": "." | ||
| }, | ||
| "features": { | ||
| "ghcr.io/devcontainers/features/github-cli:1": {} | ||
| }, | ||
| "workspaceFolder": "/workspaces", | ||
| "onCreateCommand": "uv venv .venv --seed", | ||
| "postCreateCommand": "REPO_NAME=$(basename $GITHUB_REPOSITORY) && cat $REPO_NAME/.devcontainer/init.sh >> ~/.bashrc && mkdir .vscode && cp $REPO_NAME/.devcontainer/mcp.json .vscode/", | ||
| "hostRequirements": { | ||
| "cpus": 16, | ||
| "memory": "64gb", | ||
| "storage": "128gb" | ||
| } | ||
| } | ||
| "workspaceFolder": "/workspaces/azure-cli", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the 4 folders (azure-cli, azure-cli-extensions, azure-rest-api-specs,aaz) should at the same level. why do we need to change it?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the previous configuration of the devcontainer does not work on my machine - the workspace configuration and host requirements both fail and need manual intervention to work. I have moved the workspace configuration to the init script and it is now done automatically.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps we need to follow the same level structure. although our devcontainer is in azure-cli, users usually contribute code to azure-cli-extensions and aaz, which belong to the same abstraction layer. |
||
| "postCreateCommand": "mkdir -p /workspaces/azure-cli/.vscode && cp /workspaces/azure-cli/.devcontainer/mcp.json /workspaces/azure-cli/.vscode/ && /workspaces/azure-cli/.devcontainer/init.sh" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,74 +1,89 @@ | ||
|
|
||
| source .venv/bin/activate | ||
|
|
||
| # Logout default account | ||
| export GITHUB_TOKEN= | ||
|
|
||
| # Check `repo` scope exists or not | ||
| if gh auth status -a 2>/dev/null | grep "Token scopes: " | grep -q "repo"; then | ||
| echo "You now have access to GitHub." | ||
| else | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| echo "======================================" | ||
| echo " Azure CLI Devcontainer Setup Started " | ||
| echo "======================================" | ||
|
|
||
| # ----------------------------- | ||
| # Remove existing virtual environments | ||
| # ----------------------------- | ||
| VENV_DIRS=( | ||
| "$HOME/.venv" | ||
| "/workspaces/.venv" | ||
| ) | ||
| for VENV in "${VENV_DIRS[@]}"; do | ||
| if [ -d "$VENV" ]; then | ||
| echo "Removing existing virtual environment at $VENV..." | ||
| rm -rf "$VENV" | ||
| fi | ||
| done | ||
|
|
||
| # ----------------------------- | ||
| # GitHub authentication | ||
| # ----------------------------- | ||
| export GITHUB_TOKEN=${GITHUB_TOKEN:-} | ||
| export GITHUB_USER=$(gh api user --jq .login 2>/dev/null || echo "") | ||
|
|
||
| if [ -z "$GITHUB_USER" ]; then | ||
| echo "No GitHub user detected, running gh auth login..." | ||
| gh auth login -p https -w | ||
| export GITHUB_USER=$(gh api user --jq .login || echo "unknown") | ||
| fi | ||
|
|
||
| # Check `aaz-dev` is available or not | ||
| if ! command -v aaz-dev &> /dev/null; then | ||
| GREEN="\033[0;32m" | ||
| YELLOW="\033[0;33m" | ||
| NC="\033[0m" # no color | ||
|
|
||
| set_or_add_remote() { | ||
| local REPO=$1 | ||
| local REMOTE=$2 | ||
| local DIR="/workspaces/$REPO" | ||
| local OWNER=$([ "$REMOTE" = "origin" ] && echo "$GITHUB_USER" || echo "Azure") | ||
| local URL="https://github.com/$OWNER/$REPO.git" | ||
|
|
||
| git -C "$DIR" remote get-url "$REMOTE" &>/dev/null || git -C "$DIR" remote add "$REMOTE" "$URL" | ||
| git -C "$DIR" remote set-url "$REMOTE" "$URL" | ||
| } | ||
|
|
||
| setup_repo() { | ||
| local REPO=$1 | ||
| local DIR="/workspaces/$REPO" | ||
|
|
||
| echo | ||
| echo "Using GitHub user: $GITHUB_USER" | ||
|
|
||
| # ----------------------------- | ||
| # Install aaz-dev | ||
| # ----------------------------- | ||
| pip install --upgrade pip | ||
| pip install --no-cache-dir aaz-dev | ||
|
|
||
| # ----------------------------- | ||
| # Repo paths | ||
| # ----------------------------- | ||
| export AZDEV_CLI_PATH="/workspaces/azure-cli" | ||
| export CLI_PATH="/workspaces/azure-cli" | ||
| export CLI_EXTENSION_PATH="/workspaces-src/azure-cli-extensions" | ||
| export AAZ_PATH="/workspaces-src/aaz" | ||
| export SWAGGER_PATH="/workspaces-src/azure-rest-api-specs" | ||
|
|
||
| # ----------------------------- | ||
| # Ensure /workspaces-src exists | ||
| # ----------------------------- | ||
| mkdir -p /workspaces-src | ||
|
|
||
| # ----------------------------- | ||
| # Clone repos only if they don't exist | ||
| # ----------------------------- | ||
| OTHER_REPOS=("azure-cli-extensions" "aaz" "azure-rest-api-specs") | ||
|
|
||
| for REPO in "${OTHER_REPOS[@]}"; do | ||
| DIR="/workspaces-src/$REPO" | ||
| if [ -d "$DIR/.git" ]; then | ||
| echo "$REPO already exists, skipping clone." | ||
| else | ||
| echo "Cloning $REPO..." | ||
| gh repo fork "Azure/$REPO" --clone=false --default-branch-only | ||
|
|
||
| if [ -d "$DIR" ]; then | ||
| set_or_add_remote "$REPO" origin | ||
| set_or_add_remote "$REPO" upstream | ||
| else | ||
| git clone "https://github.com/$GITHUB_USER/$REPO.git" --single-branch --no-tags | ||
| set_or_add_remote "$REPO" upstream | ||
|
|
||
| # Synchronize with upstream | ||
| BRANCH=$(git -C "$DIR" remote show upstream | grep "HEAD branch" | awk '{print $NF}') | ||
| git -C "$DIR" pull -r upstream "$BRANCH" | ||
| fi | ||
| } | ||
|
|
||
| SECONDS=0 | ||
|
|
||
| echo | ||
| uv pip install aaz-dev --link-mode=copy | ||
|
|
||
| # `azdev` repositories | ||
| setup_repo "azure-cli" | ||
| setup_repo "azure-cli-extensions" | ||
|
|
||
| azdev setup -c -r ./azure-cli-extensions | ||
|
|
||
| # `aaz-dev` repositories | ||
| setup_repo "aaz" | ||
| setup_repo "azure-rest-api-specs" | ||
|
|
||
| ELAPSED_TIME=$SECONDS | ||
|
|
||
| echo -e "\n${YELLOW}Elapsed time: $((ELAPSED_TIME / 60))m $((ELAPSED_TIME % 60))s.${NC}" | ||
| echo -e "\n${GREEN}Finished setup! Please launch the codegen tool via:${NC}" | ||
| echo -e "${GREEN}\$ aaz-dev run -c azure-cli -e azure-cli-extensions -s azure-rest-api-specs -a aaz${NC}\n" | ||
| else | ||
| echo -e "\nPlease launch the codegen tool via:" | ||
| echo -e "$ aaz-dev run -c azure-cli -e azure-cli-extensions -s azure-rest-api-specs -a aaz\n" | ||
| fi | ||
| git clone "https://github.com/$GITHUB_USER/$REPO.git" "$DIR" --single-branch --no-tags | ||
| git -C "$DIR" remote add upstream "https://github.com/Azure/$REPO.git" | ||
| git -C "$DIR" pull -r upstream main || true | ||
| fi | ||
| done | ||
|
|
||
| # ----------------------------- | ||
| # Install aaz-flow using uv (no separate venv) | ||
| # ----------------------------- | ||
| echo "Installing aaz-flow and dependencies using uv..." | ||
| cd "/workspaces/azure-cli/tools/aaz-flow" | ||
| sudo uv pip install -e . --system | ||
| cd - | ||
|
|
||
| # ----------------------------- | ||
| # Final setup | ||
| # ----------------------------- | ||
| echo "Running azdev setup..." | ||
| python3 -m venv /workspaces-src/.azdev-env | ||
| source /workspaces-src/.azdev-env/bin/activate | ||
| pip install --upgrade pip | ||
| pip install azdev | ||
| azdev setup -c /workspaces/azure-cli -r /workspaces-src/azure-cli-extensions |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,16 @@ | ||
| { | ||
| "inputs": [ | ||
| { | ||
| "type": "promptString", | ||
| "id": "extension_or_module_name", | ||
| "description": "The name of the Azure CLI extension or module to generate commands for." | ||
| }, | ||
| { | ||
| "type": "promptString", | ||
| "id": "swagger_module_path", | ||
| "description": "The file path to the Swagger module." | ||
| }, | ||
| { | ||
| "type": "promptString", | ||
| "id": "resource_provider", | ||
| "description": "The Azure resource provider for which to generate commands." | ||
| }, | ||
| { | ||
| "type": "promptString", | ||
| "id": "swagger_tag", | ||
| "description": "The Swagger tag to use for command generation." | ||
| } | ||
| ], | ||
| "servers": { | ||
| "AAZ Flow": { | ||
| "command": "python", | ||
| "args": [ | ||
| "azure-cli/tools/aaz-flow/main.py" | ||
| "tools/aaz-flow/main.py" | ||
| ], | ||
| "env": { | ||
| "AAZ_PATH": "/workspaces/aaz", | ||
| "CLI_PATH": "/workspaces/azure-cli", | ||
| "CLI_EXTENSION_PATH": "/workspaces/azure-cli-extensions", | ||
| "SWAGGER_PATH": "/workspaces/azure-rest-api-specs" | ||
| "AAZ_PATH": "/workspaces-src/aaz", | ||
| "CLI_PATH": "/workspaces-src/azure-cli", | ||
| "CLI_EXTENSION_PATH": "/workspaces-src/azure-cli-extensions", | ||
| "SWAGGER_PATH": "/workspaces-src/azure-rest-api-specs" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # AAZ Flow package |

Uh oh!
There was an error while loading. Please reload this page.