命令速查表 - AZD 必备命令 所有章节快速参考 课程主页: AZD 初学者指南 快速入门: 第1章: 基础与快速入门 AI 命令: 第2章: AI优先开发 高级内容: 第4章: 基础设施即代码 简介 这份全面的速查表按类别整理了最常用的 Azure Developer CLI 命令,并提供实用示例。非常适合在开发、故障排除以及日常操作中快速查阅 azd 项目相关内容。 学习目标 通过使用这份速查表,您将能够: 快速访问关键的 Azure Developer CLI 命令及其语法 按功能类别和使用场景理解命令组织方式 参考常见开发和部署场景的实用示例 访问故障排除命令以快速解决问题 高效找到高级配置和自定义选项 轻松定位环境管理和多环境工作流命令 学习成果
所有章节快速参考
这份全面的速查表按类别整理了最常用的 Azure Developer CLI 命令,并提供实用示例。非常适合在开发、故障排除以及日常操作中快速查阅 azd 项目相关内容。
通过使用这份速查表,您将能够:
通过定期参考这份速查表,您将能够:
# Login to Azure (uses Azure CLI) az login # Check current account az account show # Set default subscription az account set --subscription "your-subscription-id" azd config set defaults.subscription "your-subscription-id"
# Browse available templates azd template list # Initialize from template azd init --template todo-nodejs-mongo azd init --template <template-name> # Initialize in current directory azd init . # Initialize with custom name azd init --template todo-nodejs-mongo my-awesome-app
# Deploy everything (provision + deploy) azd up # Deploy with confirmation prompts disabled azd up --confirm-with-no-prompt # Deploy to specific environment azd up --environment production # Deploy with custom parameters azd up --parameter location=westus2
# Provision Azure resources azd provision # Preview infrastructure changes (NEW) azd provision --preview # Shows a dry-run view of what resources would be created/modified/deleted # Similar to 'terraform plan' or 'bicep what-if' - safe to run, no changes applied # Provision with what-if analysis azd provision --what-if
# Deploy application code azd deploy # Deploy specific service azd deploy --service web azd deploy --service api # Deploy all services azd deploy --all
# Build applications azd package # Build specific service azd package --service api
# List all environments azd env list # Create new environment azd env new development azd env new staging --location westus2 # Select environment azd env select production # Show current environment azd env show # Refresh environment state azd env refresh
# Set environment variable azd env set API_KEY "your-secret-key" azd env set DEBUG true # Get environment variable azd env get API_KEY # List all environment variables azd env get-values # Remove environment variable azd env unset DEBUG
# List all configuration azd config list # Set global defaults azd config set defaults.location eastus2 azd config set defaults.subscription "sub-id" # Remove configuration azd config unset defaults.location # Reset all configuration azd config reset
# Validate azure.yaml azd config validate # Show project information azd show # Get service endpoints azd show --output json
# View logs from all services azd logs # View logs from specific service azd logs --service api # Follow logs in real-time azd logs --follow # View logs since specific time azd logs --since 1h azd logs --since "2024-01-01 10:00:00" # Filter logs by level azd logs --level error
# Open Azure portal for monitoring azd monitor # Open Application Insights azd monitor --insights
# Remove all Azure resources azd down # Force delete without confirmation azd down --force # Purge soft-deleted resources azd down --purge # Complete cleanup azd down --force --purge
# Check for azd updates azd version --check-for-updates # Get current version azd version # Show system information azd info
# Configure GitHub Actions azd pipeline config # Configure Azure DevOps azd pipeline config --provider azdo # Show pipeline configuration azd pipeline show
# Import existing resources azd infra import # Export infrastructure template azd infra export # Validate infrastructure azd infra validate # Infrastructure Preview & Planning (NEW) azd provision --preview # Simulates infrastructure provisioning without deploying # Analyzes Bicep/Terraform templates and shows: # - Resources to be added (green +) # - Resources to be modified (yellow ~) # - Resources to be deleted (red -) # Safe to run - no actual changes made to Azure environment
# List all services azd service list # Show service details azd service show --service web # Restart service azd service restart --service api
# Start new project azd init --template todo-nodejs-mongo cd my-project # Deploy to development azd env new dev azd up # Make changes and redeploy azd deploy # View logs azd logs --follow
# Set up environments azd env new dev azd env new staging azd env new production # Deploy to dev azd env select dev azd up # Test and promote to staging azd env select staging azd up # Deploy to production azd env select production azd up
# Enable debug mode export AZD_DEBUG=true # Check system info azd info # Validate configuration azd config validate # View detailed logs azd logs --level debug --since 1h # Check resource status azd show --output json
# Enable debug output export AZD_DEBUG=true azd <command> --debug # Disable telemetry for cleaner output export AZD_DISABLE_TELEMETRY=true # Get system information azd info # Check authentication status az account show
# List available templates with details azd template list --output json # Show template information azd template show <template-name> # Validate template before init azd template validate <template-name>
# Show current directory structure tree /f # Windows find . -type f # Linux/macOS # Navigate to azd project root cd $(azd root) # Show azd configuration directory echo $AZD_CONFIG_DIR # Usually ~/.azd
# Get JSON output for scripting azd show --output json azd env list --output json azd config list --output json # Parse with jq azd show --output json | jq '.services.web.endpoint' azd env get-values --output json | jq -r '.DATABASE_URL'
# Format as table azd env list --output table azd service list --output table
#!/bin/bash # Quick health check azd show azd env show azd logs --level error --since 10m
#!/bin/bash # Pre-deployment validation azd config validate azd provision --preview # NEW: Preview changes before deploying az account show
#!/bin/bash # Compare environments for env in dev staging production; do echo "=== $env ===" azd env select $env azd show --output json | jq '.services[].endpoint' done
#!/bin/bash # Clean up old environments azd env list | grep -E "(dev-|test-)" | while read env; do echo "Cleaning up $env" azd env select $env azd down --force --purge done
# Azure configuration export AZURE_SUBSCRIPTION_ID="your-subscription-id" export AZURE_LOCATION="eastus2" export AZURE_ENV_NAME="development" # AZD configuration export AZD_DEBUG=true export AZD_DISABLE_TELEMETRY=true export AZD_CONFIG_DIR="~/.azd" # Application configuration export NODE_ENV="production" export LOG_LEVEL="info"
# Reset authentication az account clear az login # Force refresh environment azd env refresh --force # Restart all services azd service restart --all # Quick rollback azd deploy --rollback
# Recover from failed deployment azd provision --continue-on-error azd deploy --ignore-errors # Clean slate recovery azd down --force azd up --confirm-with-no-prompt
# Add to your .bashrc or .zshrc alias azdup='azd up --confirm-with-no-prompt' alias azdl='azd logs --follow' alias azds='azd show --output json' alias azde='azd env'
# Quick environment switching azd-env() { azd env select $1 && azd show } # Quick deployment with logs azd-deploy-watch() { azd deploy --service $1 && azd logs --service $1 --follow } # Environment status azd-status() { echo "Current environment: $(azd env show --output json | jq -r '.name')" echo "Services:" azd show --output json | jq -r '.services | keys[]' }
# General help azd --help azd help # Command-specific help azd up --help azd env --help azd config --help # Show version and build info azd version azd version --output json
# Open documentation in browser azd docs # Show template documentation azd template show <template-name> --docs
提示: 收藏这份速查表,并使用 Ctrl+F 快速找到您需要的命令!
导航
免责声明:
本文档使用AI翻译服务Co-op Translator进行翻译。尽管我们努力确保翻译的准确性,但请注意,自动翻译可能包含错误或不准确之处。原始语言的文档应被视为权威来源。对于重要信息,建议使用专业人工翻译。我们不对因使用此翻译而产生的任何误解或误读承担责任。