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


## templateファイルの用意

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

## 準備
### ログイン

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

### デプロイ


```bash
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](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/293481/64f60964-5ffd-c338-4e29-46ced437fb8a.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/293481/d4d17e64-a1d5-8e60-0f98-5eacdb373b1a.png)


## リソースの追加

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

```json

{
  "$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
      }
    }
  ]
}
```

### 再デプロイ

```bash

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

### 動作確認
- ストレージアカウントが作成されている
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/293481/ca7ed9a5-e431-a5a6-bf3c-9f636bbfadf3.png)


## パラメータ追加

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

```json

{
  "$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
      }
    }
  ]
}
```

### 再デプロイ

```bash

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

### 動作確認
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/293481/89fe0ba5-f7f4-ec00-b221-0cd8a38ff5a8.png)