LoginSignup
0
0

More than 3 years have passed since last update.

なんのやつだっっけ、、、

Posted at

templateファイルの用意

azuredeply.json
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": []
}

準備

ログイン

az group create \
  --name myResourceGroup \
  --location "Central US"

デプロイ

templateFile="azuredeply.json"
az deployment group create \
  --name blanktemplate \
  --resource-group myResourceGroup \
  --template-file $templateFile

出力

{- Finished ..
  "id": "/subscriptions/9611116b-ea93-42fc-bc7a-6a1149bb2521/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/blanktemplate",
  "location": null,
  "name": "blanktemplate",
  "properties": {
    "correlationId": "3f74a43b-73e3-4032-88e1-a1d00d2493ee",
    "debugSetting": null,
    "dependencies": [],
    "duration": "PT3.036297S",
    "mode": "Incremental",
    "onErrorDeployment": null,
    "outputResources": [],
    "outputs": null,
    "parameters": null,
    "parametersLink": null,
    "providers": [],
    "provisioningState": "Succeeded",
    "template": null,
    "templateHash": "11481920352792298114",
    "templateLink": null,
    "timestamp": "2020-07-10T07:02:13.126846+00:00"
  },
  "resourceGroup": "myResourceGroup",
  "type": "Microsoft.Resources/deployments"
}

動作確認

Azure Portalからデプロイの確認ができる
image.png

image.png

リソースの追加

  • ストレージアカウントの作成
  • ストレージアカウント名はユニーク名

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
        {
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2019-04-01",
      "name": "armstoragetest0910",
      "location": "eastus",
      "sku": {
        "name": "Standard_LRS"
      },
      "kind": "StorageV2",
      "properties": {
        "supportsHttpsTrafficOnly": true
      }
    }
  ]
}

再デプロイ


az deployment group create \
  --name blanktemplate \
  --resource-group myResourceGroup \
  --template-file $templateFile

動作確認

  • ストレージアカウントが作成されている image.png

パラメータ追加

  • ストレージ名を変数化
  • "name": "[parameters('storageName')]",のような感じに

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
    "parameters": {
    "storageName": {
      "type": "string",
      "minLength": 3,
      "maxLength": 24
    }
  },
  "resources": [
        {
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2019-04-01",
      "name": "[parameters('storageName')]",
      "location": "eastus",
      "sku": {
        "name": "Standard_LRS"
      },
      "kind": "StorageV2",
      "properties": {
        "supportsHttpsTrafficOnly": true
      }
    }
  ]
}

再デプロイ


az deployment group create \
  --name addskuparameter \
  --resource-group myResourceGroup \
  --template-file $templateFile \
  --parameters storageName=azurearmtest2

動作確認

image.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