0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Azure Cloud Shell で任意のバージョンの Azure CLI を使う例

Posted at

Azure Cloud Shell で以前は実行できていた Azure CLI が、自動バージョンアップにより実行できなくなっていました。その時は、他の Azure CLI 環境を使用しましたが、今後のために Azure Cloud Shell で任意のバージョンの Azure CLI を実行する方法を考えてみました。

Azure CLI でエラーが発生した例

api-version は2023-07-01-preview を使っているいるが、サポートしている api-version は、2015-05-04-preview,2016-04-01,2017-09-01,2017-09-15-preview,2017-10-01,2018-03-01-preview,2018-05-01 のどれかだよ、というエラー。

bash
$ az version
{
  "azure-cli": "2.50.0",
  "azure-cli-core": "2.50.0",
  "azure-cli-telemetry": "1.0.8",
  "extensions": {
    "ai-examples": "0.2.5",
    "ml": "2.18.0",
    "ssh": "1.1.6"
  }
}

$ az network dns zone list -o table
(InvalidResourceType) The resource type 'dnszones' could not be found in the namespace 'Microsoft.Network' for api version '2023-07-01-preview'. The supported api-versions are '2015-05-04-preview,2016-04-01,2017-09-01,2017-09-15-preview,2017-10-01,2018-03-01-preview,2018-05-01'.
Code: InvalidResourceType
Message: The resource type 'dnszones' could not be found in the namespace 'Microsoft.Network' for api version '2023-07-01-preview'. The supported api-versions are '2015-05-04-preview,2016-04-01,2017-09-01,2017-09-15-preview,2017-10-01,2018-03-01-preview,2018-05-01'.

任意のバージョンの Azure CLI をインストール

bash
$ pip install azure-cli==2.49.0

$ export OLDPATH=$PATH

$ export PATH=~/.local/bin:$PATH

$ az version
{
  "azure-cli": "2.49.0",
  "azure-cli-core": "2.49.0",
  "azure-cli-telemetry": "1.0.8",
  "extensions": {
    "ai-examples": "0.2.5",
    "ml": "2.18.0",
    "ssh": "1.1.6"
  }
}

先ほどエラーになった Azure CLI を実行

bash
$ az network dns zone list -o table
ZoneName     ResourceGroup    RecordSets    MaxRecordSets
-----------  ---------------  ------------  ---------------
mnrsdev.com  mnrlabo-rg       7             10000

Azure CLI のバージョンを戻す

bash
$ export PATH=$OLDPATH

$ az version
{
  "azure-cli": "2.50.0",
  "azure-cli-core": "2.50.0",
  "azure-cli-telemetry": "1.0.8",
  "extensions": {
    "ai-examples": "0.2.5",
    "ml": "2.18.0",
    "ssh": "1.1.6"
  }
}

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?