ARM 템플릿의 배열 함수

이 문서에서는 배열 작업을 위한 템플릿 함수를 설명합니다.

값으로 구분되는 문자열 값의 배열을 가져오려면 split을 참조하세요.

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

배열

array(convertToArray)

값을 배열로 변환합니다.

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

매개 변수

매개 변수 필수 Type 설명
convertToArray int, 문자열, 배열 또는 개체 배열로 변환할 값입니다.

반환 값

배열입니다.

예시

다음 예제에서는 여러 다른 형식의 배열 함수를 사용하는 방법을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "intToConvert": {
      "type": "int",
      "defaultValue": 1
    },
    "stringToConvert": {
      "type": "string",
      "defaultValue": "efgh"
    },
    "objectToConvert": {
      "type": "object",
      "defaultValue": {
        "a": "b",
        "c": "d"
      }
    }
  },
  "resources": [
  ],
  "outputs": {
    "intOutput": {
      "type": "array",
      "value": "[array(parameters('intToConvert'))]"
    },
    "stringOutput": {
      "type": "array",
      "value": "[array(parameters('stringToConvert'))]"
    },
    "objectOutput": {
      "type": "array",
      "value": "[array(parameters('objectToConvert'))]"
    }
  }
}

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

이름 타입
intOutput 배열 [1]
stringOutput 배열 ["efgh"]
objectOutput 배열 [{"a": "b", "c": "d"}]

concat

concat(arg1, arg2, arg3, ...)

여러 배열을 결합하고 연결된 배열을 반환하거나 여러 문자열 값을 결합하고 연결된 문자열을 반환합니다.

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

매개 변수

매개 변수 필수 Type 설명
arg1 배열 또는 문자열 연결을 위한 첫 번째 배열 또는 문자열입니다.
더 많은 인수 아니요 배열 또는 문자열 연결을 위해 순차적으로 더 많은 배열 또는 문자열입니다.

이 함수는 인수를 개수에 관계없이 사용할 수 있으며 매개 변수에 대한 문자열이나 배열 중 하나를 사용할 수 있습니다. 그러나 매개 변수에 대한 배열과 문자열을 둘 다 제공할 수는 없습니다. 배열은 다른 배열과만 연결됩니다.

반환 값

연결된 값의 문자열 또는 배열입니다.

예시

다음 예제에서는 두 개의 배열을 결합하는 방법을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "firstArray": {
      "type": "array",
      "defaultValue": [
        "1-1",
        "1-2",
        "1-3"
      ]
    },
    "secondArray": {
      "type": "array",
      "defaultValue": [
        "2-1",
        "2-2",
        "2-3"
      ]
    }
  },
  "resources": [
  ],
  "outputs": {
    "return": {
      "type": "array",
      "value": "[concat(parameters('firstArray'), parameters('secondArray'))]"
    }
  }
}

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

이름 타입
return 배열 ["1-1", "1-2", "1-3", "2-1", "2-2", "2-3"]

다음 예제에서는 2개의 문자열 값을 결합하고 연결된 문자열을 반환하는 방법을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "prefix": {
      "type": "string",
      "defaultValue": "prefix"
    }
  },
  "resources": [],
  "outputs": {
    "concatOutput": {
      "type": "string",
      "value": "[concat(parameters('prefix'), '-', uniqueString(resourceGroup().id))]"
    }
  }
}

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

이름 타입
concatOutput 문자열 prefix-5yj4yjf5mbg72

contains

contains(container, itemToFind)

배열에 값이 포함되는지, 개체에 키가 포함되는지 또는 문자열에 하위 문자열이 포함되는지를 확인합니다. 문자열 비교에서는 대/소문자를 구분합니다. 그러나 개체에 키가 포함되어 있는지를 테스트할 때는 비교에서 대/소문자를 구분하지 않습니다.

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

매개 변수

매개 변수 필수 Type 설명
컨테이너 배열, 개체 또는 문자열 찾을 값을 포함하는 값입니다.
itemToFind 문자열 또는 int 찾을 값입니다.

반환 값

항목이 있으면 True이고, 항목이 없으면 False입니다.

예시

다음 예제에서는 여러 다른 형식의 contains를 사용하는 방법을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "stringToTest": {
      "type": "string",
      "defaultValue": "OneTwoThree"
    },
    "objectToTest": {
      "type": "object",
      "defaultValue": {
        "one": "a",
        "two": "b",
        "three": "c"
      }
    },
    "arrayToTest": {
      "type": "array",
      "defaultValue": [ "one", "two", "three" ]
    }
  },
  "resources": [
  ],
  "outputs": {
    "stringTrue": {
      "type": "bool",
      "value": "[contains(parameters('stringToTest'), 'e')]"
    },
    "stringFalse": {
      "type": "bool",
      "value": "[contains(parameters('stringToTest'), 'z')]"
    },
    "objectTrue": {
      "type": "bool",
      "value": "[contains(parameters('objectToTest'), 'one')]"
    },
    "objectFalse": {
      "type": "bool",
      "value": "[contains(parameters('objectToTest'), 'a')]"
    },
    "arrayTrue": {
      "type": "bool",
      "value": "[contains(parameters('arrayToTest'), 'three')]"
    },
    "arrayFalse": {
      "type": "bool",
      "value": "[contains(parameters('arrayToTest'), 'four')]"
    }
  }
}

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

이름 타입
stringTrue Bool True
stringFalse Bool False
objectTrue Bool True
objectFalse Bool False
arrayTrue Bool True
arrayFalse Bool False

createArray

createArray(arg1, arg2, arg3, ...)

매개 변수에서 배열을 만듭니다.

createArray 함수는 Bicep에서 지원되지 않습니다. 배열을 생성하려면 Bicep 배열 데이터 형식을 참조하세요.

매개 변수

매개 변수 필수 Type 설명
args 아니요 문자열, 정수, 배열 또는 개체 배열의 값입니다.

반환 값

배열입니다. 제공된 매개 변수가 없는 경우 빈 배열을 반환합니다.

예시

다음 예제에서는 여러 다른 형식의 createArray를 사용하는 방법을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "objectToTest": {
      "type": "object",
      "defaultValue": {
        "one": "a",
        "two": "b",
        "three": "c"
      }
    },
    "arrayToTest": {
      "type": "array",
      "defaultValue": [ "one", "two", "three" ]
    }
  },
  "resources": [
  ],
  "outputs": {
    "stringArray": {
      "type": "array",
      "value": "[createArray('a', 'b', 'c')]"
    },
    "intArray": {
      "type": "array",
      "value": "[createArray(1, 2, 3)]"
    },
    "objectArray": {
      "type": "array",
      "value": "[createArray(parameters('objectToTest'))]"
    },
    "arrayArray": {
      "type": "array",
      "value": "[createArray(parameters('arrayToTest'))]"
    },
    "emptyArray": {
      "type": "array",
      "value": "[createArray()]"
    }
  }
}

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

이름 타입
stringArray 배열 ["a", "b", "c"]
intArray 배열 [1, 2, 3]
objectArray 배열 [{"one": "a", "two": "b", "three": "c"}]
arrayArray 배열 [["one", "two", "three"]]
emptyArray 배열 []

empty

empty(itemToTest)

배열, 개체 또는 문자열이 비어 있는지를 확인합니다.

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

매개 변수

매개 변수 필수 Type 설명
itemToTest 배열, 개체 또는 문자열 비어 있는지 확인할 값입니다.

반환 값

값이 비어 있으면 True를 반환하고 비어 있지 않으면 False를 반환합니다.

예시

다음 예제에서는 배열, 개체 및 문자열이 비어 있는지 여부를 확인합니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "testArray": {
      "type": "array",
      "defaultValue": []
    },
    "testObject": {
      "type": "object",
      "defaultValue": {}
    },
    "testString": {
      "type": "string",
      "defaultValue": ""
    }
  },
  "resources": [
  ],
  "outputs": {
    "arrayEmpty": {
      "type": "bool",
      "value": "[empty(parameters('testArray'))]"
    },
    "objectEmpty": {
      "type": "bool",
      "value": "[empty(parameters('testObject'))]"
    },
    "stringEmpty": {
      "type": "bool",
      "value": "[empty(parameters('testString'))]"
    }
  }
}

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

이름 타입
arrayEmpty Bool True
objectEmpty Bool True
stringEmpty Bool True

첫째

first(arg1)

배열의 첫 번째 요소 또는 문자열의 첫 번째 문자를 반환합니다.

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

매개 변수

매개 변수 필수 Type 설명
arg1 배열 또는 문자열 첫 번째 요소 또는 문자를 검색할 값입니다.

반환 값

배열의 첫 번째 요소 또는 문자열의 첫 번째 문자에 대한 형식(문자열, int, 배열 또는 개체)입니다.

예시

다음 예제에서는 배열 및 문자열에 첫 번째 함수를 사용하는 방법을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "arrayToTest": {
      "type": "array",
      "defaultValue": [ "one", "two", "three" ]
    }
  },
  "resources": [
  ],
  "outputs": {
    "arrayOutput": {
      "type": "string",
      "value": "[first(parameters('arrayToTest'))]"
    },
    "stringOutput": {
      "type": "string",
      "value": "[first('One Two Three')]"
    }
  }
}

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

이름 타입
arrayOutput 문자열 1
stringOutput 문자열 O

indexof

indexOf(arrayToSearch, itemToFind)

배열에서 항목이 처음 나타나는 인덱스의 정수를 반환합니다. 비교는 문자열에 대/소문자를 구분합니다.

매개 변수

매개 변수 필수 Type 설명
arrayToSearch 배열 검색된 항목의 인덱스를 찾는 데 사용할 배열입니다.
itemToFind int, 문자열, 배열 또는 개체 배열에서 찾을 항목입니다.

반환 값

배열에 있는 항목의 첫 번째 인덱스를 나타내는 정수입니다. 인덱스는 0부터 시작합니다. 항목을 찾을 수 없으면 -1이 반환됩니다.

예제

다음 예제에서는 indexOf 및 lastIndexOf 함수를 사용하는 방법을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "variables": {
    "names": [
      "one",
      "two",
      "three"
    ],
    "numbers": [
      4,
      5,
      6
    ],
    "collection": [
      "[variables('names')]",
      "[variables('numbers')]"
    ],
    "duplicates": [
      1,
      2,
      3,
      1
    ]
  },
  "resources": [],
  "outputs": {
    "index1": {
      "type": "int",
      "value": "[lastIndexOf(variables('names'), 'two')]"
    },
    "index2": {
      "type": "int",
      "value": "[indexOf(variables('names'), 'one')]"
    },
    "notFoundIndex1": {
      "type": "int",
      "value": "[lastIndexOf(variables('names'), 'Three')]"
    },
    "index3": {
      "type": "int",
      "value": "[lastIndexOf(variables('numbers'), 4)]"
    },
    "index4": {
      "type": "int",
      "value": "[indexOf(variables('numbers'), 6)]"
    },
    "notFoundIndex2": {
      "type": "int",
      "value": "[lastIndexOf(variables('numbers'), '5')]"
    },
    "index5": {
      "type": "int",
      "value": "[indexOf(variables('collection'), variables('numbers'))]"
    },
    "index6": {
      "type": "int",
      "value": "[indexOf(variables('duplicates'), 1)]"
    },
    "index7": {
      "type": "int",
      "value": "[lastIndexOf(variables('duplicates'), 1)]"
    }
  }
}

위 예제의 출력은 다음과 같습니다.

이름 타입
index1 int 1
index2 int 0
index3 int 0
index4 int 2
index5 int 1
index6 int 0
index7 int 3
notFoundIndex1 int -1
notFoundIndex2 int -1

교집합

intersection(arg1, arg2, arg3, ...)

매개 변수에서 공통 요소를 갖는 단일 배열 또는 개체를 반환합니다.

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

매개 변수

매개 변수 필수 Type 설명
arg1 배열 또는 개체 공통 요소를 찾는 데 사용할 첫 번째 값입니다.
arg2 배열 또는 개체 공통 요소를 찾는 데 사용할 두 번째 값입니다.
더 많은 인수 아니요 배열 또는 개체 일반적인 요소를 찾는 데 사용할 더 많은 값입니다.

반환 값

공통 요소가 있는 배열 또는 개체입니다.

예시

다음 예제에서는 배열 및 개체에 intersection을 사용하는 방법을 보여줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "firstObject": {
      "type": "object",
      "defaultValue": {
        "one": "a",
        "two": "b",
        "three": "c"
      }
    },
    "secondObject": {
      "type": "object",
      "defaultValue": {
        "one": "a",
        "two": "z",
        "three": "c"
      }
    },
    "firstArray": {
      "type": "array",
      "defaultValue": [ "one", "two", "three" ]
    },
    "secondArray": {
      "type": "array",
      "defaultValue": [ "two", "three" ]
    }
  },
  "resources": [
  ],
  "outputs": {
    "objectOutput": {
      "type": "object",
      "value": "[intersection(parameters('firstObject'), parameters('secondObject'))]"
    },
    "arrayOutput": {
      "type": "array",
      "value": "[intersection(parameters('firstArray'), parameters('secondArray'))]"
    }
  }
}

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

이름 타입
objectOutput Object {"one": "a", "three": "c"}
arrayOutput 배열 ["two", "three"]

마지막

last(arg1)

배열의 마지막 요소 또는 문자열의 마지막 문자를 반환합니다.

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

매개 변수

매개 변수 필수 Type 설명
arg1 배열 또는 문자열 마지막 요소 또는 문자를 검색할 값입니다.

반환 값

배열의 마지막 요소 또는 문자열의 마지막 문자에 대한 형식(문자열, int, 배열 또는 개체)입니다.

예시

다음 예제에서는 배열 및 문자열에 마지막 함수를 사용하는 방법을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "arrayToTest": {
      "type": "array",
      "defaultValue": [ "one", "two", "three" ]
    }
  },
  "resources": [
  ],
  "outputs": {
    "arrayOutput": {
      "type": "string",
      "value": "[last(parameters('arrayToTest'))]"
    },
    "stringOutput": {
      "type": "string",
      "value": "[last('One Two Three')]"
    }
  }
}

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

이름 타입
arrayOutput 문자열 three
stringOutput 문자열 e

lastindexof

lastIndexOf(arrayToSearch, itemToFind)

배열에서 항목이 마지막으로 나타나는 인덱스의 정수를 반환합니다. 비교는 문자열에 대/소문자를 구분합니다.

매개 변수

매개 변수 필수 Type 설명
arrayToSearch 배열 검색된 항목의 인덱스를 찾는 데 사용할 배열입니다.
itemToFind int, 문자열, 배열 또는 개체 배열에서 찾을 항목입니다.

반환 값

배열에 있는 항목의 마지막 인덱스를 나타내는 정수입니다. 인덱스는 0부터 시작합니다. 항목을 찾을 수 없으면 -1이 반환됩니다.

예제

다음 예제에서는 indexOf 및 lastIndexOf 함수를 사용하는 방법을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "variables": {
    "names": [
      "one",
      "two",
      "three"
    ],
    "numbers": [
      4,
      5,
      6
    ],
    "collection": [
      "[variables('names')]",
      "[variables('numbers')]"
    ],
    "duplicates": [
      1,
      2,
      3,
      1
    ]
  },
  "resources": [],
  "outputs": {
    "index1": {
      "type": "int",
      "value": "[lastIndexOf(variables('names'), 'two')]"
    },
    "index2": {
      "type": "int",
      "value": "[indexOf(variables('names'), 'one')]"
    },
    "notFoundIndex1": {
      "type": "int",
      "value": "[lastIndexOf(variables('names'), 'Three')]"
    },
    "index3": {
      "type": "int",
      "value": "[lastIndexOf(variables('numbers'), 4)]"
    },
    "index4": {
      "type": "int",
      "value": "[indexOf(variables('numbers'), 6)]"
    },
    "notFoundIndex2": {
      "type": "int",
      "value": "[lastIndexOf(variables('numbers'), '5')]"
    },
    "index5": {
      "type": "int",
      "value": "[indexOf(variables('collection'), variables('numbers'))]"
    },
    "index6": {
      "type": "int",
      "value": "[indexOf(variables('duplicates'), 1)]"
    },
    "index7": {
      "type": "int",
      "value": "[lastIndexOf(variables('duplicates'), 1)]"
    }
  }
}

위 예제의 출력은 다음과 같습니다.

이름 타입
index1 int 1
index2 int 0
index3 int 0
index4 int 2
index5 int 1
index6 int 0
index7 int 3
notFoundIndex1 int -1
notFoundIndex2 int -1

length

length(arg1)

배열의 요소 수, 문자열의 문자 수 또는 개체의 루트 수준 속성 수를 반환합니다.

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

매개 변수

매개 변수 필수 Type 설명
arg1 배열, 문자열 또는 개체 요소의 수를 가져오는 데 사용할 배열, 문자 수를 가져오는 데 사용할 문자열 또는 루트 수준의 속성 수를 가져오려는 데 사용할 개체입니다.

반환 값

int입니다.

예시

다음 예제에서는 배열 및 문자열에 length를 사용하는 방법을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "arrayToTest": {
      "type": "array",
      "defaultValue": [
        "one",
        "two",
        "three"
      ]
    },
    "stringToTest": {
      "type": "string",
      "defaultValue": "One Two Three"
    },
    "objectToTest": {
      "type": "object",
      "defaultValue": {
        "propA": "one",
        "propB": "two",
        "propC": "three",
        "propD": {
          "propD-1": "sub",
          "propD-2": "sub"
        }
      }
    }
  },
  "resources": [],
  "outputs": {
    "arrayLength": {
      "type": "int",
      "value": "[length(parameters('arrayToTest'))]"
    },
    "stringLength": {
      "type": "int",
      "value": "[length(parameters('stringToTest'))]"
    },
    "objectLength": {
      "type": "int",
      "value": "[length(parameters('objectToTest'))]"
    }
  }
}

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

이름 타입
arrayLength 정수 3
stringLength 정수 13
objectLength 정수 4

배열과 함께 이 함수를 사용하면 리소스를 만들 때 반복 횟수를 지정할 수 있습니다. 다음 예제에서 매개 변수 siteNames 는 웹 사이트를 만들 때 사용할 이름 배열을 나타냅니다.

"copy": {
  "name": "websitescopy",
  "count": "[length(parameters('siteNames'))]"
}

배열에서 이 함수를 사용하는 방법에 대한 자세한 내용은 ARM 템플릿의 리소스 반복을 참조하세요.

최대

max(arg1)

정수 배열 또는 쉼표로 구분된 정수 목록 중에서 최대값을 반환합니다.

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

매개 변수

매개 변수 필수 Type 설명
arg1 정수 배열 또는 쉼표로 구분된 정수 목록 최대값을 가져올 컬렉션입니다.

반환 값

최대값을 나타내는 int입니다.

예시

다음 예제에서는 정수 배열 및 목록에 max를 사용하는 방법을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "arrayToTest": {
      "type": "array",
      "defaultValue": [ 0, 3, 2, 5, 4 ]
    }
  },
  "resources": [],
  "outputs": {
    "arrayOutput": {
      "type": "int",
      "value": "[max(parameters('arrayToTest'))]"
    },
    "intOutput": {
      "type": "int",
      "value": "[max(0,3,2,5,4)]"
    }
  }
}

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

이름 타입
arrayOutput 정수 5
intOutput 정수 5

최소

min(arg1)

정수 배열 또는 쉼표로 구분된 정수 목록 중에서 최소값을 반환합니다.

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

매개 변수

매개 변수 필수 Type 설명
arg1 정수 배열 또는 쉼표로 구분된 정수 목록 최소값을 가져올 컬렉션입니다.

반환 값

최소값을 나타내는 int입니다.

예시

다음 예제에서는 정수 배열 및 목록에 min을 사용하는 방법을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "arrayToTest": {
      "type": "array",
      "defaultValue": [ 0, 3, 2, 5, 4 ]
    }
  },
  "resources": [],
  "outputs": {
    "arrayOutput": {
      "type": "int",
      "value": "[min(parameters('arrayToTest'))]"
    },
    "intOutput": {
      "type": "int",
      "value": "[min(0,3,2,5,4)]"
    }
  }
}

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

이름 타입
arrayOutput 정수 0
intOutput 정수 0

range

range(startIndex, count)

시작 정수 및 항목의 수를 포함하는 정수 배열을 만듭니다.

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

매개 변수

매개 변수 필수 Type 설명
startIndex int 배열에서 첫 번째 정수입니다. startIndex 및 count의 합계는 2,147,483,647 이하여야 합니다.
count int 배열에 있는 정수의 수입니다. 음수가 아닌 정수(최대 10.000)여야 합니다.

반환 값

정수 배열입니다.

예시

다음 예제에서는 range 함수를 사용하는 방법을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "startingInt": {
      "type": "int",
      "defaultValue": 5
    },
    "numberOfElements": {
      "type": "int",
      "defaultValue": 3
    }
  },
  "resources": [],
  "outputs": {
    "rangeOutput": {
      "type": "array",
      "value": "[range(parameters('startingInt'),parameters('numberOfElements'))]"
    }
  }
}

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

이름 타입
rangeOutput 배열 [5, 6, 7]

skip

skip(originalValue, numberToSkip)

배열에서 지정된 숫자 이후의 모든 요소를 포함하는 배열을 반환하거나 문자열에서 지정된 숫자 이후의 모든 숫자를 포함하는 문자열을 반환합니다.

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

매개 변수

매개 변수 필수 Type 설명
originalValue 배열 또는 문자열 건너뛰는 데 사용할 배열 또는 문자열입니다.
numberToSkip int 건너뛸 요소 또는 문자 수입니다. 이 값이 0 이하이면 값의 모든 요소 또는 문자가 반환됩니다. 이 값이 배열 또는 문자열의 길이보다 크면 빈 배열 또는 문자열이 반환됩니다.

반환 값

배열 또는 문자열입니다.

예시

다음 예제에서는 배열에서 지정된 요소 수 및 문자열에서 지정된 수의 문자를 건너뜁니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "testArray": {
      "type": "array",
      "defaultValue": [
        "one",
        "two",
        "three"
      ]
    },
    "elementsToSkip": {
      "type": "int",
      "defaultValue": 2
    },
    "testString": {
      "type": "string",
      "defaultValue": "one two three"
    },
    "charactersToSkip": {
      "type": "int",
      "defaultValue": 4
    }
  },
  "resources": [],
  "outputs": {
    "arrayOutput": {
      "type": "array",
      "value": "[skip(parameters('testArray'),parameters('elementsToSkip'))]"
    },
    "stringOutput": {
      "type": "string",
      "value": "[skip(parameters('testString'),parameters('charactersToSkip'))]"
    }
  }
}

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

이름 타입
arrayOutput 배열 ["three"]
stringOutput 문자열 two three

take

take(originalValue, numberToTake)

배열 또는 문자열을 반환합니다. 배열에는 배열 시작부터 지정된 수의 요소가 있습니다. 문자열은 문자열의 시작 부분부터 지정된 수의 문자를 갖습니다.

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

매개 변수

매개 변수 필수 Type 설명
originalValue 배열 또는 문자열 요소를 가져올 배열 또는 문자열입니다.
numberToTake int 수락할 요소 또는 문자의 수입니다. 이 값이 0 이하이면 빈 배열 또는 문자열이 반환됩니다. 지정된 배열 또는 문자열의 길이보다 크면 배열 또는 문자열의 모든 요소가 반환됩니다.

반환 값

배열 또는 문자열입니다.

예시

다음 예제에서는 배열에서 지정된 수의 요소 및 문자열의 문자를 가져옵니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "testArray": {
      "type": "array",
      "defaultValue": [
        "one",
        "two",
        "three"
      ]
    },
    "elementsToTake": {
      "type": "int",
      "defaultValue": 2
    },
    "testString": {
      "type": "string",
      "defaultValue": "one two three"
    },
    "charactersToTake": {
      "type": "int",
      "defaultValue": 2
    }
  },
  "resources": [],
  "outputs": {
    "arrayOutput": {
      "type": "array",
      "value": "[take(parameters('testArray'),parameters('elementsToTake'))]"
    },
    "stringOutput": {
      "type": "string",
      "value": "[take(parameters('testString'),parameters('charactersToTake'))]"
    }
  }
}

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

이름 타입
arrayOutput 배열 ["one", "two"]
stringOutput 문자열 On

union

union(arg1, arg2, arg3, ...)

매개 변수의 모든 요소를 포함하는 단일 배열 또는 개체를 반환합니다. 배열의 경우 중복 값이 한 번 포함됩니다. 개체의 경우 중복 속성 이름은 한 번만 포함됩니다.

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

매개 변수

매개 변수 필수 Type 설명
arg1 배열 또는 개체 요소를 조인하는 데 사용할 첫 번째 값입니다.
arg2 배열 또는 개체 요소를 조인하는 데 사용할 두 번째 값입니다.
더 많은 인수 아니요 배열 또는 개체 요소를 조인하는 데 사용할 더 많은 값입니다.

반환 값

배열 또는 개체입니다.

설명

union 함수는 매개 변수의 시퀀스를 사용하여 결과의 순서와 값을 결정합니다.

배열의 경우 함수는 첫 번째 매개 변수의 각 요소를 반복하고 아직 존재하지 않는 경우 결과에 추가합니다. 그런 다음, 두 번째 매개 변수 및 추가 매개 변수에 대한 프로세스를 반복합니다. 값이 이미 있는 경우 배열의 이전 배치가 유지됩니다.

개체의 경우 첫 번째 매개 변수의 속성 이름과 값이 결과에 추가됩니다. 후자 매개 변수의 경우 결과에 새 이름이 추가됩니다. 후자 매개 변수에 동일한 이름의 속성이 있는 경우 해당 값은 기존 값을 덮어씁니다. 속성의 순서가 보장되지 않습니다.

Union 함수는 최상위 요소뿐만 아니라 해당 요소 내의 중첩된 개체를 재귀적으로 병합합니다. 중첩된 배열 값은 병합되지 않습니다. 다음 섹션의 두 번째 예제를 참조하세요.

예시

다음 예제에서는 배열 및 개체에 union을 사용하는 방법을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "firstObject": {
      "type": "object",
      "defaultValue": {
        "one": "a",
        "two": "b",
        "three": "c1"
      }
    },
    "secondObject": {
      "type": "object",
      "defaultValue": {
        "three": "c2",
        "four": "d",
        "five": "e"
      }
    },
    "firstArray": {
      "type": "array",
      "defaultValue": [ "one", "two", "three" ]
    },
    "secondArray": {
      "type": "array",
      "defaultValue": [ "three", "four" ]
    }
  },
  "resources": [
  ],
  "outputs": {
    "objectOutput": {
      "type": "object",
      "value": "[union(parameters('firstObject'), parameters('secondObject'))]"
    },
    "arrayOutput": {
      "type": "array",
      "value": "[union(parameters('firstArray'), parameters('secondArray'))]"
    }
  }
}

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

이름 타입
objectOutput Object {"one": "a", "two": "b", "three": "c2", "four": "d", "five": "e"}
arrayOutput 배열 ["one", "two", "three", "four"]

다음 예제에서는 딥 병합 기능을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "variables": {
    "firstObject": {
      "property": {
        "one": "a",
        "two": "b",
        "three": "c1"
      },
      "nestedArray": [
        1,
        2
      ]
    },
    "secondObject": {
      "property": {
        "three": "c2",
        "four": "d",
        "five": "e"
      },
      "nestedArray": [
        3,
        4
      ]
    },
    "firstArray": [
      [
        "one",
        "two"
      ],
      [
        "three"
      ]
    ],
    "secondArray": [
      [
        "three"
      ],
      [
        "four",
        "two"
      ]
    ]
  },
  "resources": [],
  "outputs": {
    "objectOutput": {
      "type": "Object",
      "value": "[union(variables('firstObject'), variables('secondObject'))]"
    },
    "arrayOutput": {
      "type": "Array",
      "value": "[union(variables('firstArray'), variables('secondArray'))]"
    }
  }
}

위 예제의 출력은 다음과 같습니다.

이름 타입
objectOutput Object {"property":{"one":"a","two":"b","three":"c2","four":"d","five":"e"},"nestedArray":[3,4]}
arrayOutput 배열 [["one","two"],["three"],["four","two"]]

중첩된 배열이 병합된 경우 objectOutput.nestedArray 값은 [1, 2, 3, 4]이고 arrayOutput 값은 [["one", "two", "three"], ["three", "four", "two"]]입니다.

다음 단계