You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/resource-declaration.md
+20-1Lines changed: 20 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Declare resources in Bicep
3
3
description: Describes how to declare resources to deploy in Bicep.
4
4
ms.topic: conceptual
5
5
ms.custom: devx-track-bicep
6
-
ms.date: 04/28/2025
6
+
ms.date: 10/24/2025
7
7
---
8
8
9
9
# Resource declaration in Bicep
@@ -68,6 +68,7 @@ Decorators are written in the format `@expression` and are placed above resource
68
68
| --------- | ----------- | ------- |
69
69
|[batchSize](./bicep-import.md#export-variables-types-and-functions)| none | Set up instances to deploy sequentially. |
70
70
|[description](#description)| string | Provide descriptions for the resource. |
71
+
|[onlyIfNotExists](#onlyifnotexists)| none | Deploy the resource only if it doesn't already exist in the target scope. |
71
72
72
73
Decorators are in the [sys namespace](bicep-functions.md#namespaces-for-functions). If you need to differentiate a decorator from another item with the same name, preface the decorator with `sys`. For example, if your Bicep file includes a parameter named `description`, you must add the sys namespace when using the **description** decorator.
Markdown-formatted text can be used for the description text.
101
102
103
+
### onlyIfNotExists
104
+
105
+
By default, when a Bicep deployment runs, Azure Resource Manager (ARM) creates the resource if it doesn’t exist or updates it if it does. If an existing resource has properties that differ from your template, ARM might attempt to update it—or fail if updates aren’t permitted.
106
+
107
+
Starting with Bicep version v0.38.3, the `@onlyIfNotExists()` decorator instructs ARM to create the resource only if it does not already exist. If a resource with the resource ID is found, ARM skips creation and leaves the existing resource unchanged.
108
+
109
+
```bicep
110
+
@onlyIfNotExists()
111
+
resource example 'Microsoft.Storage/storageAccounts@2025-01-01' = {
112
+
name: 'mystorageacct'
113
+
location: resourceGroup().location
114
+
kind: 'StorageV2'
115
+
sku: {
116
+
name: 'Standard_LRS'
117
+
}
118
+
}
119
+
```
120
+
102
121
## Resource name
103
122
104
123
Each resource has a name. When setting the resource name, pay attention to the [rules and restrictions for resource names](../management/resource-name-rules.md).
0 commit comments