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 Automation でパブリックプレビューの Azure CLI 実行を試してみた

Posted at

現時点ではパブリックプレビューなのですが、Azure Automation で Azure CLI が実行できるようになったのでやってみました。

検証用 Azure Automation を作成

Azure Automation を作って、マネージド ID を有効にして、リソースグループに共同作成者ロールを割り当てて、検証用のランブックを作成します。

bash
prefix=mnrauto
region=japaneast

az group create \
  --name ${prefix}-rg \
  --location $region

az automation account create \
  --automation-account-name ${prefix} \
  --resource-group ${prefix}-rg \
  --sku Free

az resource update \
  --ids $(az automation account show \
  --automation-account-name ${prefix} \
  --resource-group ${prefix}-rg \
  --query id \
  --output tsv) \
  --set "identity.type=systemassigned"

az role assignment create \
  --assignee $(az automation account show \
  --automation-account-name ${prefix} \
  --resource-group ${prefix}-rg \
  --query identity.principalId \
  --output tsv) \
  --scope $(az group show \
  --name ${prefix}-rg \
  --query id \
  --output tsv) \
  --role "Contributor"

resourceid=$(az automation account show \
  --automation-account-name ${prefix} \
  --resource-group ${prefix}-rg \
  --query id \
  --output tsv)

az rest \
  --method put \
  --url "https://management.azure.com${resourceid}/runbooks/${prefix}-test?api-version=2023-05-15-preview" \
  --body '{ 
  "properties": { 
        "runbookType": "PowerShell72"
    }, 
   "location": "japaneast"
}'

Runbook に Azure CLI コードを追加

azure-automation-cli-in-runbook-01.png

Runbook の実行結果

azure-automation-cli-in-runbook-02.png

参考

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?