ARM 템플릿의 배포 함수

Resource Manager는 Azure Resource Manager 템플릿(ARM 템플릿)의 현재 배포와 관련된 값을 가져오기 위한 다음 함수를 제공합니다.

리소스, 리소스 그룹 또는 구독에서 값을 가져오려면 리소스 함수를 참조하세요.

ARM 템플릿과 동일한 기능을 제공하고 구문이 사용하기 더 쉽기 때문에 Bicep를 권장합니다. 자세한 내용은 배포 함수를 참조하세요.

확인

deployment()

현재 배포 작업에 대한 정보를 반환합니다.

Bicep에서 deployment 함수를 사용합니다.

반환 값

이 함수는 배포하는 동안 전달되는 개체를 반환합니다. 반환된 개체의 속성은 다음 여부에 따라 달라집니다.

  • 템플릿 또는 템플릿 사양 배포
  • 로컬 파일인 템플릿 배포 또는 URI를 통해 액세스할 수 있는 원격 파일인 템플릿 배포
  • 리소스 그룹에 배포 또는 기타 범위(Azure 구독, 관리 그룹 또는 테넌트) 중 하나에 배포

리소스 그룹에 로컬 템플릿을 배포하는 경우: 함수가 다음 형식을 반환합니다.

{
  "name": "",
  "properties": {
    "template": {
      "$schema": "",
      "contentVersion": "",
      "parameters": {},
      "variables": {},
      "resources": [],
      "outputs": {}
    },
    "templateHash": "",
    "parameters": {},
    "mode": "",
    "provisioningState": ""
  }
}

리소스 그룹에 원격 템플릿을 배포하는 경우: 함수가 다음 형식을 반환합니다.

{
  "name": "",
  "properties": {
    "templateLink": {
      "uri": ""
    },
    "template": {
      "$schema": "",
      "contentVersion": "",
      "parameters": {},
      "variables": {},
      "resources": [],
      "outputs": {}
    },
    "templateHash": "",
    "parameters": {},
    "mode": "",
    "provisioningState": ""
  }
}

리소스 그룹에 템플릿 사양을 배포하는 경우: 함수가 다음 형식을 반환합니다.

{
  "name": "",
  "properties": {
    "templateLink": {
      "id": ""
    },
    "template": {
      "$schema": "",
      "contentVersion": "",
      "parameters": {},
      "variables": {},
      "resources": [],
      "outputs": {}
    },
    "templateHash": "",
    "parameters": {},
    "mode": "",
    "provisioningState": ""
  }
}

Azure 구독, 관리 그룹 또는 테넌트에 배포하는 경우 반환 개체에는 location 속성이 포함됩니다. 로컬 템플릿 또는 외부 템플릿을 배포할 때 위치 속성이 포함됩니다. 형식:

{
  "name": "",
  "location": "",
  "properties": {
    "template": {
      "$schema": "",
      "contentVersion": "",
      "resources": [],
      "outputs": {}
    },
    "templateHash": "",
    "parameters": {},
    "mode": "",
    "provisioningState": ""
  }
}

languageVersion 2.0 템플릿을 배포할 때 deployment 함수는 제한된 속성 하위 집합을 반환합니다.

{
  "name": "",
  "location": "",
  "properties": {
    "template": {
      "contentVersion": ""
    },
    "templateLink": {
      "id": "",
      "uri": ""
    }
  }
}

설명

deployment()를 사용하여 부모 템플릿의 URI를 기반으로 하는 다른 템플릿에 연결할 수 있습니다.

"variables": {
  "sharedTemplateUrl": "[uri(deployment().properties.templateLink.uri, 'shared-resources.json')]"
}

포털의 배포 기록에서 템플릿을 다시 배포하는 경우 템플릿은 로컬 파일로 배포됩니다. templateLink 속성은 배포 함수에 반환되지 않습니다. 템플릿이 templateLink를 사용하여 다른 템플릿과의 링크를 설정하는 경우 포털을 사용하여 다시 배포하지 마세요. 대신 처음에 템플릿을 배포하는 데 사용한 명령을 사용하세요.

예시

다음 예제에서는 배포 개체를 반환합니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [],
  "outputs": {
    "deploymentOutput": {
      "type": "object",
      "value": "[deployment()]"
    }
  }
}

앞의 예제에서는 다음 개체를 반환합니다.

{
  "name": "deployment",
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "resources": [],
      "outputs": {
        "deploymentOutput": {
          "type": "Object",
          "value": "[deployment()]"
        }
      }
    },
    "templateHash": "13135986259522608210",
    "parameters": {},
    "mode": "Incremental",
    "provisioningState": "Accepted"
  }
}

구독 배포의 경우 다음 예제에서는 배포 개체를 반환합니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {},
  "variables": {},
  "resources": [],
  "outputs": {
    "exampleOutput": {
      "type": "object",
      "value": "[deployment()]"
    }
  }
}

environment

environment()

배포에 사용되는 Azure 환경에 대한 정보를 반환합니다.

Bicep에서 environment 함수를 사용합니다.

설명

계정에 등록된 환경 목록을 보려면 az cloud list 또는 Get-AzEnvironment를 사용합니다.

반환 값

이 함수는 현재 Azure 환경에 대한 속성을 반환합니다. 다음 예제는 전체 Azure에 대한 속성을 보여 줍니다. 소버린 클라우드가 반환하는 속성은 약간 다를 수 있습니다.

{
  "name": "",
  "gallery": "",
  "graph": "",
  "portal": "",
  "graphAudience": "",
  "activeDirectoryDataLake": "",
  "batch": "",
  "media": "",
  "sqlManagement": "",
  "vmImageAliasDoc": "",
  "resourceManager": "",
  "authentication": {
    "loginEndpoint": "",
    "audiences": [
      "",
      ""
    ],
    "tenant": "",
    "identityProvider": ""
  },
  "suffixes": {
    "acrLoginServer": "",
    "azureDatalakeAnalyticsCatalogAndJob": "",
    "azureDatalakeStoreFileSystem": "",
    "azureFrontDoorEndpointSuffix": "",
    "keyvaultDns": "",
    "sqlServerHostname": "",
    "storage": ""
  }
}

예시

다음 예제 템플릿은 환경 개체를 반환합니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [],
  "outputs": {
    "environmentOutput": {
      "type": "object",
      "value": "[environment()]"
    }
  }
}

위의 예제는 전체 Azure에 배포되는 경우 다음 개체를 반환합니다.

{
  "name": "AzureCloud",
  "gallery": "https://gallery.azure.com/",
  "graph": "https://graph.windows.net/",
  "portal": "https://portal.azure.com",
  "graphAudience": "https://graph.windows.net/",
  "activeDirectoryDataLake": "https://datalake.azure.net/",
  "batch": "https://batch.core.windows.net/",
  "media": "https://rest.media.azure.net",
  "sqlManagement": "https://management.core.windows.net:8443/",
  "vmImageAliasDoc": "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-compute/quickstart-templates/aliases.json",
  "resourceManager": "https://management.azure.com/",
  "authentication": {
    "loginEndpoint": "https://login.microsoftonline.com/",
    "audiences": [
      "https://management.core.windows.net/",
      "https://management.azure.com/"
    ],
    "tenant": "common",
    "identityProvider": "AAD"
  },
  "suffixes": {
    "acrLoginServer": ".azurecr.io",
    "azureDatalakeAnalyticsCatalogAndJob": "azuredatalakeanalytics.net",
    "azureDatalakeStoreFileSystem": "azuredatalakestore.net",
    "azureFrontDoorEndpointSuffix": "azurefd.net",
    "keyvaultDns": ".vault.azure.net",
    "sqlServerHostname": ".database.windows.net",
    "storage": "core.windows.net"
  }
}

매개 변수

parameters(parameterName)

매개 변수 값을 반환합니다. 템플릿의 매개 변수 섹션에서 지정된 매개 변수 이름을 정의해야 합니다.

Bicep에서는 해당 기호 이름을 사용하여 매개 변수를 직접 참조합니다.

매개 변수

매개 변수 필수 Type 설명
parameterName string 반환할 매개 변수의 이름입니다.

반환 값

지정한 매개 변수의 값입니다.

설명

일반적으로 매개 변수를 사용하여 리소스 값을 설정합니다. 다음 예제에서는 웹 사이트의 이름을 배포 중에 전달된 매개 변수 값으로 설정합니다.

"parameters": {
  "siteName": {
    "type": "string"
  }
}, "resources": [
  {
    "type": "Microsoft.Web/Sites",
    "apiVersion": "2016-08-01",
    "name": "[parameters('siteName')]",
    ...
  }
]

예시

다음 예에서는 매개 변수 함수의 간소화된 사용을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "stringParameter": {
      "type": "string",
      "defaultValue": "option 1"
    },
    "intParameter": {
      "type": "int",
      "defaultValue": 1
    },
    "objectParameter": {
      "type": "object",
      "defaultValue": {
        "one": "a",
        "two": "b"
      }
    },
    "arrayParameter": {
      "type": "array",
      "defaultValue": [ 1, 2, 3 ]
    },
    "crossParameter": {
      "type": "string",
      "defaultValue": "[parameters('stringParameter')]"
    }
  },
  "variables": {},
  "resources": [],
  "outputs": {
    "stringOutput": {
      "type": "string",
      "value": "[parameters('stringParameter')]"
    },
    "intOutput": {
      "type": "int",
      "value": "[parameters('intParameter')]"
    },
    "objectOutput": {
      "type": "object",
      "value": "[parameters('objectParameter')]"
    },
    "arrayOutput": {
      "type": "array",
      "value": "[parameters('arrayParameter')]"
    },
    "crossOutput": {
      "type": "string",
      "value": "[parameters('crossParameter')]"
    }
  }
}

기본 값을 사용한 이전 예제의 출력은 다음과 같습니다.

이름 타입
stringOutput 문자열 옵션 1
intOutput 정수 1
objectOutput Object {“one”: “a”, “two”: “b”}
arrayOutput 배열 [1, 2, 3]
crossOutput 문자열 옵션 1

매개 변수에 대한 자세한 내용은 ARM 템플릿의 매개 변수를 참조하세요.

variables

variables(variableName)

변수의 값을 반환합니다. 템플릿의 변수 섹션에서 지정된 변수 이름을 정의해야 합니다.

Bicep에서는 기호 이름을 사용하여 변수를 직접 참조합니다.

매개 변수

매개 변수 필수 Type 설명
variableName 문자열 반환할 변수의 이름입니다.

반환 값

지정한 변수의 값입니다.

설명

일반적으로 복잡한 값을 한 번만 구성하여 템플릿을 간소화하기 위해 변수를 사용합니다. 다음 예제에서는 스토리지 계정에 대한 고유한 이름을 생성합니다.

"variables": {
  "storageName": "[concat('storage', uniqueString(resourceGroup().id))]"
},
"resources": [
  {
    "type": "Microsoft.Storage/storageAccounts",
    "name": "[variables('storageName')]",
    ...
  },
  {
    "type": "Microsoft.Compute/virtualMachines",
    "dependsOn": [
      "[variables('storageName')]"
    ],
    ...
  }
],

예시

다음 예제에서는 각기 다른 변수 값을 반환합니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {},
  "variables": {
    "var1": "myVariable",
    "var2": [ 1, 2, 3, 4 ],
    "var3": "[ variables('var1') ]",
    "var4": {
      "property1": "value1",
      "property2": "value2"
    }
  },
  "resources": [],
  "outputs": {
    "exampleOutput1": {
      "type": "string",
      "value": "[variables('var1')]"
    },
    "exampleOutput2": {
      "type": "array",
      "value": "[variables('var2')]"
    },
    "exampleOutput3": {
      "type": "string",
      "value": "[variables('var3')]"
    },
    "exampleOutput4": {
      "type": "object",
      "value": "[variables('var4')]"
    }
  }
}

기본 값을 사용한 이전 예제의 출력은 다음과 같습니다.

이름 타입
exampleOutput1 문자열 myVariable
exampleOutput2 배열 [1, 2, 3, 4]
exampleOutput3 문자열 myVariable
exampleOutput4 Object {“property1”: “value1”, “property2”: “value2”}

변수를 사용하는 방법에 대한 자세한 내용은 ARM 템플릿의 변수를 참조하세요.

다음 단계