2024. 12. 13. 14:38

Resource Manager 템플릿(~) / Azure Portal 에서 내보낸 템플릿 사용.

- 자습

자습서 - Azure Portal에서 템플릿 내보내기 - Azure Resource Manager | Microsoft Learn

 

자습서 - Azure Portal에서 템플릿 내보내기 - Azure Resource Manager

내보낸 템플릿을 사용하여 템플릿 개발을 완료하는 방법을 알아봅니다.

learn.microsoft.com

 

 

 

 

 

 

 중요

일반적으로 내보낸 템플릿은 템플릿을 만들 때 필요한 것보다 더 자세한 정보를 포함합니다. 예를 들어 내보낸 템플릿의 SKU 개체에는 5개의 속성이 있습니다. 이 템플릿도 괜찮지만 name 속성만 사용할 수 있습니다. 내보낸 템플릿으로 시작한 다음, 요구 사항에 맞게 원하는 대로 수정할 수 있습니다.

 

 

-- MS 문서상 내용.

잘 이해가 안감... 일단 기재해놓음.

 

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "storagePrefix": {
      "type": "string",
      "minLength": 3,
      "maxLength": 11
    },
    "storageSKU": {
      "type": "string",
      "defaultValue": "Standard_LRS",
      "allowedValues": [
        "Standard_LRS",
        "Standard_GRS",
        "Standard_RAGRS",
        "Standard_ZRS",
        "Premium_LRS",
        "Premium_ZRS",
        "Standard_GZRS",
        "Standard_RAGZRS"
      ]
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]"
    },
    "appServicePlanName": {
      "type": "string",
      "defaultValue": "exampleplan"
    }
  },
  "variables": {
    "uniqueStorageName": "[concat(parameters('storagePrefix'), uniqueString(resourceGroup().id))]"
  },
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2021-09-01",
      "name": "[variables('uniqueStorageName')]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "[parameters('storageSKU')]"
      },
      "kind": "StorageV2",
      "properties": {
        "supportsHttpsTrafficOnly": true
      }
    },
    {
      "type": "Microsoft.Web/serverfarms",
      "apiVersion": "2021-03-01",
      "name": "[parameters('appServicePlanName')]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "B1",
        "tier": "Basic",
        "size": "B1",
        "family": "B",
        "capacity": 1
      },
      "kind": "linux",
      "properties": {
        "perSiteScaling": false,
        "reserved": true,
        "targetWorkerCount": 0,
        "targetWorkerSizeId": 0
      }
    }
  ],
  "outputs": {
    "storageEndpoint": {
      "type": "object",
      "value": "[reference(variables('uniqueStorageName')).primaryEndpoints]"
    }
  }
}

 

 

 

-- 템플릿 배포

New-AzResourceGroupDeployment -Name addappserviceplan -ResourceGroupName myResourceGroup -TemplateFile $templateFile -storagePrefix "store" -storageSKU Standard_LRS