Skip to content

Commit f6669c8

Browse files
committed
ARM objectkeys function
1 parent 095cb36 commit f6669c8

File tree

2 files changed

+60
-11
lines changed

2 files changed

+60
-11
lines changed

articles/azure-resource-manager/bicep/bicep-functions-object.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Namespace: [sys](bicep-functions.md#namespaces-for-functions).
3131

3232
### Example
3333

34-
The following example shows how to use contains with different types:
34+
The following example shows how to use `contains` with different types:
3535

3636
```bicep
3737
param stringToTest string = 'OneTwoThree'
@@ -127,7 +127,7 @@ An array or object with the common elements.
127127

128128
### Example
129129

130-
The following example shows how to use intersection with arrays and objects:
130+
The following example shows how to use `intersection` with arrays and objects:
131131

132132
```bicep
133133
param firstObject object = {
@@ -301,7 +301,7 @@ If you need to include a parameter value or variable in the JSON object, use the
301301

302302
### Example
303303

304-
The following example shows how to use the json function. Notice that you can pass in **null** for an empty object.
304+
The following example shows how to use the `json` function. Notice that you can pass in **null** for an empty object.
305305

306306
```bicep
307307
param jsonEmptyObject string = 'null'
@@ -353,7 +353,7 @@ An int.
353353

354354
### Example
355355

356-
The following example shows how to use length with an array and string:
356+
The following example shows how to use `length` with an array and string:
357357

358358
```bicep
359359
param arrayToTest array = [
@@ -405,7 +405,7 @@ An array.
405405

406406
### Example
407407

408-
The following example shows how to use length with an array and string:
408+
The following example shows how to use `objectKeys` with an object:
409409

410410
```bicep
411411
var obj = { a: 1, b: 2 }
@@ -452,7 +452,7 @@ The union function merges not only the top-level elements but also recursively m
452452

453453
### Example
454454

455-
The following example shows how to use union with arrays and objects:
455+
The following example shows how to use `union` with arrays and objects:
456456

457457
```bicep
458458
param firstObject object = {

articles/azure-resource-manager/templates/template-functions-object.md

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Template functions - objects
33
description: Describes the functions to use in an Azure Resource Manager template (ARM template) for working with objects.
44
ms.topic: conceptual
55
ms.custom: devx-track-arm-template
6-
ms.date: 01/11/2024
6+
ms.date: 05/09/2024
77
---
88

99
# Object functions for ARM templates
@@ -44,7 +44,7 @@ In Bicep, use the [contains](../bicep/bicep-functions-object.md#contains) functi
4444

4545
### Example
4646

47-
The following example shows how to use contains with different types:
47+
The following example shows how to use `contains` with different types:
4848

4949
:::code language="json" source="~/resourcemanager-templates/azure-resource-manager/functions/array/contains.json":::
5050

@@ -154,7 +154,7 @@ An array or object with the common elements.
154154

155155
### Example
156156

157-
The following example shows how to use intersection with arrays and objects.
157+
The following example shows how to use `intersection` with arrays and objects.
158158

159159
:::code language="json" source="~/resourcemanager-templates/azure-resource-manager/functions/array/intersection.json":::
160160

@@ -369,7 +369,7 @@ An int.
369369

370370
### Example
371371

372-
The following example shows how to use length with an array and string:
372+
The following example shows how to use `length` with an array and string:
373373

374374
:::code language="json" source="~/resourcemanager-templates/azure-resource-manager/functions/array/length.json":::
375375

@@ -409,6 +409,55 @@ The output from the preceding example is:
409409
| ---- | ---- | ----- |
410410
| emptyOutput | Bool | True |
411411

412+
## objectKeys
413+
414+
`objectKey(arg1)`
415+
416+
Returns the keys from an object, where an object is a collection of key-value pairs.
417+
418+
In Bicep, use the [objectKeys](../templates/template-functions-object.md#objectkeys) function.
419+
420+
### Parameters
421+
422+
| Parameter | Required | Type | Description |
423+
|:--- |:--- |:--- |:--- |
424+
| arg1 |Yes |object |The object which is a collection of key-value pairs. |
425+
426+
### Return value
427+
428+
An array.
429+
430+
### Example
431+
432+
The following example shows how to use `objectKeys` with an object:
433+
434+
```json
435+
{
436+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
437+
"contentVersion": "1.0.0.0",
438+
"variables": {
439+
"obj": {
440+
"a": 1,
441+
"b": 2
442+
},
443+
"keys": "[objectKeys(variables('obj'))]"
444+
},
445+
"resources": [],
446+
"outputs": {
447+
"keyArray": {
448+
"type": "array",
449+
"value": "[variables('keys')]"
450+
}
451+
}
452+
}
453+
```
454+
455+
The output from the preceding example is:
456+
457+
| Name | Type | Value |
458+
| ---- | ---- | ----- |
459+
| keyArray | Array | [ "a", "b" ] |
460+
412461
## union
413462

414463
`union(arg1, arg2, arg3, ...)`
@@ -441,7 +490,7 @@ The union function merges not only the top-level elements but also recursively m
441490

442491
### Example
443492

444-
The following example shows how to use union with arrays and objects:
493+
The following example shows how to use `union` with arrays and objects:
445494

446495
:::code language="json" source="~/resourcemanager-templates/azure-resource-manager/functions/array/union.json":::
447496

0 commit comments

Comments
 (0)