Azure Developer CLI (azd) を使用すると、一連のazd config コマンドを使用してazd構成を管理できます。 これらの構成設定には、Azureサブスクリプションや場所などの便利な既定値のほか、他のazdコマンドや機能で使用される設定が含まれます。 独自のカスタム値を取得して設定し、スクリプトやカスタム機能で使用することもできます。
この記事では、次の内容について解説します:
- Azure Developer CLI の構成に関する主要な概念
-
azd configコマンドを使用する方法 -
azd configを他のazd機能と統合する方法
Azure Developer CLI 構成ファイルを調べる
Azure Developer CLI を初めてインストールすると、config.jsonという名前のファイルが次の場所に追加されます。
- Linux と macOS の場合:
$HOME/.azd - Windows の場合:
%USERPROFILE%\.azd
Tip
構成ディレクトリは、 AZD_CONFIG_DIR 環境変数にパスを指定することでオーバーライドできます。
このファイルの設定は、次のような機能を管理します。
- リソースをプロビジョニングまたはデプロイするときに使用する既定のAzureサブスクリプションまたは場所
- 有効になっているアルファ機能
- どのテンプレート ソースの場所が構成済みか
- スクリプトまたはその他の目的でユーザーが設定したカスタム値
既定では、 config.json ファイルには、既定の azd テンプレート ソースの場所に関する構成がいくつか含まれています。 Azure Developer CLI のさまざまな機能を使用すると、一部の値が自動的にconfig.jsonに設定されます。 たとえば、 azd up コマンドを初めて実行すると、プロビジョニングとデプロイ用に選択したサブスクリプションと場所が、ファイルの defaults セクションに格納されます。
単純な config.json ファイルは次のようになります。
{
"defaults": {
"location": "eastus2",
"subscription": "your-subscription-id"
},
"template": {
"sources": {
"awesome-azd": {
"key": "awesome-azd",
"location": "https://aka.ms/awesome-azd/templates.json",
"name": "Awesome AZD",
"type": "awesome-azd"
},
"default": {
"key": "default",
"name": "default"
}
}
}
}
構成コマンドの操作
Azure Developer CLI には、config.json ファイルの設定を手動で管理するための一連のコマンドが用意されています。
-
azd config get: 構成値を取得します。 -
azd config list-alpha: アルファ ステージで使用可能な機能の一覧を表示します。 -
azd config reset: 構成を既定値にリセットします。 -
azd config set: 構成を設定します。 -
azd config show: すべての構成値を表示します。 -
azd config unset: 構成の設定を解除します。
これらのコマンドについては、次のセクションで詳しく説明します。
azd コマンドの詳細については、Azure Developer CLI コマンド リファレンス ページを参照してください。
ディスプレイの構成
azd config show コマンドを実行して、config.json ファイル全体の現在の内容をいつでも表示します。
azd config show
サンプル出力:
{
"defaults": {
"location": "eastus2",
"subscription": "your-subscription-id"
},
"template": {
"sources": {
"awesome-azd": {
"key": "awesome-azd",
"location": "https://aka.ms/awesome-azd/templates.json",
"name": "Awesome AZD",
"type": "awesome-azd"
},
"default": {
"key": "default",
"name": "default"
}
}
}
}
azd config get <key> コマンドを使用して、特定の構成値を表示します。
azd config get defaults
サンプル出力:
"defaults": {
"location": "eastus2",
"subscription": "your-subscription-id"
}
アルファ機能の有効化または無効化は一般的な構成タスクであるため、 azd にはアルファ機能の現在の状態を表示する便利なコマンドも含まれています。
azd config list-alpha
サンプル出力:
Name: aca.persistDomains
Description: Do not change custom domains when deploying Azure Container Apps.
Status: Off
Name: aca.persistIngressSessionAffinity
Description: Do not change Ingress Session Affinity when deploying Azure Container Apps.
Status: Off
Name: aks.helm
Description: Enable Helm support for AKS deployments.
Status: On
Name: aks.kustomize
Description: Enable Kustomize support for AKS deployments.
Status: Off
Name: azd.operations
Description: Extends provisioning providers with azd operations.
Status: Off
Name: deployment.stacks
Description: Enables Azure deployment stacks for ARM/Bicep based deployments.
Status: Off
Name: llm
Description: Enables the use of LLMs in the CLI.
Status: Off
構成の取得と設定
azd config コマンドを使用して、config.json ファイル内の値を取得、設定、または設定解除できます。 アルファ機能の有効化やテンプレート ソースの設定など、一部の特定の構成は他の azd 機能やコマンドで使用されますが、独自のカスタム値を設定することもできます。
azd で使用される構成を管理する
azd config set <key> <value> コマンドを使用して、config.json ファイルに構成設定を追加します。
たとえば、GitHub Copilot統合で使用される LLM 機能を有効にするには、次のようにします。
azd config set alpha.llm on
注
azd init中に [Set up with GitHub Copilot (プレビュー)] を選択すると、この設定が自動的に有効になります。
.構文を使用して、構成値を取得および設定するときに JSON オブジェクト構造を走査します。
次のように、 azd config get <key> コマンドを使用して設定が有効になっていることを確認します。
azd config get alpha.llm
サンプル出力:
"on"
このシナリオでは、 azd config get alpha を実行して、 config.json ファイル内の JSON オブジェクト全体を表示することもできます。
azd config get alpha
サンプル出力:
{
"llm": "on"
}
カスタム構成の管理
azdフックや顧客スクリプトで使用するカスタム構成値を設定することもできます。 これらの構成値は、環境変数を使用する代わりに使用できます。
カスタム構成値を設定するには:
azd config get customVal hello-world
カスタム構成値を取得します。
azd config get customVal
サンプル出力:
hello-world
構成をリセットする
Azure Developer CLI config.json ファイルを既定値にリセットするには、azd config reset コマンドを使用してファイルの内容を削除します。
azd config reset
リセット後に azd config show を実行すると、空のオブジェクトが表示されます。
{}