コンテンツにスキップ

Azure CLI

| コマンド | 説明 | |---------|-------------| | az login | Azure にログインする | | az login --service-principal -u <app-id> -p <password> --tenant <tenant> | サービスプリンシパルでログイン | | az logout | Azureからログアウト | | az account list | すべてのサブスクリプションを一覧表示 | | az account set --subscription "subscription-name" | アクティブサブスクリプションを設定 | | az account show | 現在のサブスクリプションを表示 | | az configure | Azure CLI の設定を構成する |Microsoft Azureクラウドサービスを管理するための、仮想マシン、ストレージ、Azure Active Directoryを含む包括的なAzure CLIコマンドとワークフロー。

コマンド説明
az group listすべてのリソースグループを一覧表示
az group create --name myResourceGroup --location eastusリソースグループを作成
az group delete --name myResourceGroupリソースグループを削除
az group show --name myResourceGroupリソースグループの詳細を表示
az group update --name myResourceGroup --tags environment=productionリソースグループのタグを更新
コマンド説明
az vm listすべてのVMをリスト表示
az vm create --resource-group myResourceGroup --name myVM --image UbuntuLTS --admin-username azureuser --generate-ssh-keysVMを作成
az vm start --resource-group myResourceGroup --name myVMVMを起動
az vm stop --resource-group myResourceGroup --name myVMVMを停止
az vm restart --resource-group myResourceGroup --name myVMVMを再起動
az vm delete --resource-group myResourceGroup --name myVMVMを削除
az vm deallocate --resource-group myResourceGroup --name myVMVMの割り当て解除
コマンド説明
az vm show --resource-group myResourceGroup --name myVMVMの詳細を表示
az vm list-sizes --location eastus利用可能なVMサイズの一覧
az vm image list --output table人気のVMイメージの一覧
az vm image list --publisher Canonical --output tableパブリッシャー別に画像を一覧表示
az vm get-instance-view --resource-group myResourceGroup --name myVMVMインスタンスのビューを取得
コマンド説明
az vm extension list --resource-group myResourceGroup --vm-name myVMVMの拡張機能を一覧表示
az vm extension set --resource-group myResourceGroup --vm-name myVM --name customScript --publisher Microsoft.Azure.Extensions --settings '\\{"fileUris":["https://example.com/script.sh"],"commandToExecute":"sh script.sh"\\}'拡張機能をインストール
az vm extension delete --resource-group myResourceGroup --vm-name myVM --name customScript拡張子を削除
コマンド説明
az storage account listストレージアカウントの一覧
az storage account create --name mystorageaccount --resource-group myResourceGroup --location eastus --sku Standard_LRSストレージアカウントを作成
az storage account delete --name mystorageaccount --resource-group myResourceGroupストレージアカウントを削除
az storage account show --name mystorageaccount --resource-group myResourceGroupストレージアカウントの詳細を表示
az storage account keys list --account-name mystorageaccount --resource-group myResourceGroupストレージアカウントキーの一覧
コマンド説明
az storage container list --account-name mystorageaccountコンテナをリスト
az storage container create --name mycontainer --account-name mystorageaccountコンテナを作成
az storage container delete --name mycontainer --account-name mystorageaccountコンテナを削除
az storage blob upload --file myfile.txt --container-name mycontainer --name myblob --account-name mystorageaccountBlobをアップロード
az storage blob download --container-name mycontainer --name myblob --file myfile.txt --account-name mystorageaccountBlobをダウンロード
az storage blob list --container-name mycontainer --account-name mystorageaccountBLOBをリスト
コマンド説明
az storage share list --account-name mystorageaccountファイル共有の一覧
az storage share create --name myshare --account-name mystorageaccountファイル共有を作成
az storage file upload --share-name myshare --source myfile.txt --account-name mystorageaccountファイルをアップロード
az storage file download --share-name myshare --path myfile.txt --dest myfile.txt --account-name mystorageaccountファイルをダウンロード
コマンド説明
az webapp listWebアプリの一覧
`az webapp create —resource-group myResourceGroup —plan myAppServicePlan —name myWebApp —runtime “NODE14-lts”`
az webapp delete --resource-group myResourceGroup --name myWebAppWebアプリを削除
az webapp start --resource-group myResourceGroup --name myWebAppWebアプリを起動
az webapp stop --resource-group myResourceGroup --name myWebAppWebアプリを停止
az webapp restart --resource-group myResourceGroup --name myWebAppWebアプリを再起動
コマンド説明
az appservice plan listApp サービスプランを一覧表示
az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku B1アプリ サービス プランを作成
az appservice plan delete --name myAppServicePlan --resource-group myResourceGroupアプリ サービス プランを削除
az appservice plan update --name myAppServicePlan --resource-group myResourceGroup --sku S1アプリ サービス プランを更新
コマンド説明
az webapp deployment source config --resource-group myResourceGroup --name myWebApp --repo-url https://github.com/user/repo --branch masterGit デプロイメントを設定する
az webapp deployment source sync --resource-group myResourceGroup --name myWebAppデプロイメントの同期
az webapp log tail --resource-group myResourceGroup --name myWebAppストリームログ
az webapp config appsettings set --resource-group myResourceGroup --name myWebApp --settings key=valueアプリの設定
コマンド説明
az functionapp list関数アプリの一覧
az functionapp create --resource-group myResourceGroup --consumption-plan-location eastus --runtime node --name myFunctionApp --storage-account mystorageaccount関数アプリを作成する
az functionapp delete --resource-group myResourceGroup --name myFunctionApp関数アプリを削除
az functionapp start --resource-group myResourceGroup --name myFunctionAppStart function app の関数アプリを起動
az functionapp stop --resource-group myResourceGroup --name myFunctionApp関数アプリを停止
コマンド説明
az functionapp function list --resource-group myResourceGroup --name myFunctionApp関数のリスト
az functionapp function show --resource-group myResourceGroup --name myFunctionApp --function-name myFunction関数の詳細を表示
az functionapp function delete --resource-group myResourceGroup --name myFunctionApp --function-name myFunction削除関数
コマンド説明
az sql server listSQLサーバーの一覧
az sql server create --name myserver --resource-group myResourceGroup --location eastus --admin-user myadmin --admin-password myPassword123!SQL サーバーを作成する
az sql server delete --name myserver --resource-group myResourceGroupSQLサーバーを削除
az sql server show --name myserver --resource-group myResourceGroupSQL サーバーの詳細を表示
コマンド説明
az sql db list --resource-group myResourceGroup --server myserverデータベースをリスト
az sql db create --resource-group myResourceGroup --server myserver --name mydatabase --service-objective S0データベースを作成する
az sql db delete --resource-group myResourceGroup --server myserver --name mydatabaseデータベースを削除
az sql db show --resource-group myResourceGroup --server myserver --name mydatabaseデータベースの詳細を表示
コマンド説明
az sql server firewall-rule list --resource-group myResourceGroup --server myserverファイアウォールルールをリスト
az sql server firewall-rule create --resource-group myResourceGroup --server myserver --name AllowMyIP --start-ip-address 192.168.1.1 --end-ip-address 192.168.1.1ファイアウォールルールを作成
az sql server firewall-rule delete --resource-group myResourceGroup --server myserver --name AllowMyIPファイアウォールルールを削除
コマンド説明
az ad user listユーザーを一覧表示
az ad user create --display-name "John Doe" --password myPassword123! --user-principal-name john@contoso.comユーザーを作成
az ad user delete --id john@contoso.comユーザーを削除
az ad user show --id john@contoso.comユーザーの詳細を表示
az ad user update --id john@contoso.com --display-name "John Smith"ユーザーを更新
コマンド説明
az ad group listグループを一覧表示
az ad group create --display-name "My Group" --mail-nickname mygroupグループを作成
az ad group delete --group mygroupグループを削除
az ad group member add --group mygroup --member-id john@contoso.comグループにメンバーを追加
az ad group member remove --group mygroup --member-id john@contoso.comグループからメンバーを削除
コマンド説明
az ad app listアプリケーションをリスト
az ad app create --display-name "My App"アプリケーションを作成
az ad app delete --id <app-id>アプリケーションを削除
az ad app show --id <app-id>アプリケーションの詳細を表示

Azure Kubernetes Service (AKS)

クラスター管理

コマンド説明
az aks listAKSクラスターの一覧
az aks create --resource-group myResourceGroup --name myAKSCluster --node-count 1 --enable-addons monitoring --generate-ssh-keysAKSクラスターを作成
az aks delete --resource-group myResourceGroup --name myAKSClusterAKSクラスターを削除
az aks start --resource-group myResourceGroup --name myAKSClusterAKSクラスターを開始
az aks stop --resource-group myResourceGroup --name myAKSClusterAKSクラスターを停止

クラスター操作

コマンド説明
az aks get-credentials --resource-group myResourceGroup --name myAKSClusterクラスター資格情報を取得
az aks scale --resource-group myResourceGroup --name myAKSCluster --node-count 3クラスターをスケール
az aks upgrade --resource-group myResourceGroup --name myAKSCluster --kubernetes-version 1.21.1クラスターをアップグレード
az aks show --resource-group myResourceGroup --name myAKSClusterクラスターの詳細を表示

Azure Container Registry (ACR)

レジストリ管理

コマンド説明
az acr listコンテナレジストリの一覧
az acr create --resource-group myResourceGroup --name myregistry --sku Basicコンテナレジストリを作成
az acr delete --resource-group myResourceGroup --name myregistryコンテナレジストリを削除
az acr login --name myregistryレジストリにログイン

イメージ管理

コマンド説明
az acr repository list --name myregistryリポジトリをリスト表示
az acr repository show-tags --name myregistry --repository myapp画像タグを表示
az acr repository delete --name myregistry --repository myapp --tag v1.0画像タグを削除
docker tag myapp:latest myregistry.azurecr.io/myapp:v1.0ACRのイメージにタグ付け
docker push myregistry.azurecr.io/myapp:v1.0ACRにイメージをプッシュ

ネットワーキング

仮想ネットワーク

コマンド説明
az network vnet list仮想ネットワークの一覧
az network vnet create --resource-group myResourceGroup --name myVNet --address-prefix 10.0.0.0/16仮想ネットワークを作成
az network vnet delete --resource-group myResourceGroup --name myVNet仮想ネットワークを削除
az network vnet subnet create --resource-group myResourceGroup --vnet-name myVNet --name mySubnet --address-prefix 10.0.1.0/24サブネットを作成

ネットワークセキュリティグループ

コマンド説明
az network nsg listネットワークセキュリティグループを一覧表示
az network nsg create --resource-group myResourceGroup --name myNSGNSGを作成
az network nsg rule create --resource-group myResourceGroup --nsg-name myNSG --name myRule --protocol tcp --priority 1000 --destination-port-range 80NSGルールを作成
az network nsg rule delete --resource-group myResourceGroup --nsg-name myNSG --name myRuleNSGルールを削除

ロードバランサー

コマンド説明
az network lb listロードバランサーの一覧
az network lb create --resource-group myResourceGroup --name myLoadBalancer --sku Standard --public-ip-address myPublicIPロードバランサーを作成
az network lb delete --resource-group myResourceGroup --name myLoadBalancerロードバランサーを削除

モニタリングとログ記録

Azure Monitor

コマンド説明
az monitor metrics list --resource <resource-id>メトリクスのリスト
az monitor metrics list-definitions --resource <resource-id>メトリクス定義のリスト
az monitor log-analytics workspace listLog Analytics ワークスペースの一覧
az monitor log-analytics workspace create --resource-group myResourceGroup --workspace-name myWorkspaceワークスペースを作成

アラート

コマンド説明
az monitor alert listアラートをリスト
az monitor alert create --name myAlert --resource-group myResourceGroup --condition "avg Percentage CPU > 80"アラートを作成
az monitor alert delete --name myAlert --resource-group myResourceGroupアラートを削除

ベストプラクティス

セキュリティ