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
|**Comparison**| Compares code vs. a saved file | Compares code vs. live Azure state |
734
+
|**Speed**| Extremely fast | Slower (requires API calls) |
735
+
|**Use Case**| Refactoring and logic testing | Final pre-deployment check |
736
+
719
737
### Provide context
720
738
721
-
If your Bicep file relies on environmental functions (like `subscription().id`), pass mock values to ensure the snapshot is accurate:
739
+
When running bicep snapshot, the CLI performs a local evaluation of your code. Since it doesn't talk to Azure, it cannot "ask" the cloud for your Subscription ID or the current Resource Group name.
740
+
741
+
If your code uses environment functions (like `subscription().id`), the snapshot will fail or return placeholders unless you provide specific context via CLI arguments.
742
+
743
+
To simulate a real deployment environment, you can pass the following flags:
744
+
745
+
| Argument | Purpose | Example Value |
746
+
| :--- | :--- | :--- |
747
+
|`--subscription-id`| Replaces the value returned by `subscription().subscriptionId`|`00000000-1111-2222-3333-444444444444`|
748
+
|`--resource-group`| Replaces the value returned by `resourceGroup().name`|`my-production-rg`|
749
+
|`--location`| Sets the default location for `deployment().location`|`westeurope`|
750
+
|`--tenant-id`| Replaces the value returned by `tenant().tenantId`|`72f988bf-86f1-41af-91ab-2d7cd011db47`|
751
+
|`--management-group`| Replaces the value returned by `managementGroup().name`|`my-corp-mg`|
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/deploy-what-if.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,9 +15,7 @@ ms.custom:
15
15
16
16
Before deploying a Bicep file, you can preview the changes that will happen. Azure Resource Manager provides the what-if operation to let you see how resources will change if you deploy the Bicep file. The what-if operation doesn't make any changes to existing resources. Instead, it predicts the changes if the specified Bicep file is deployed.
17
17
18
-
The [`bicep snapshot`](./bicep-cli.md#snapshot) command performs local-only testing by generating and comparing a normalized JSON representation of your infrastructure to catch unintended logic changes without requiring an Azure connection. For a comparison, see [Comparison snapshot vs what-if](./bicep-cli.md#comparison-snapshot-vs-what-if).
19
-
20
-
Would you like me to show you the specific JSON structure it generates?
18
+
Similar to what-if, the [`bicep snapshot`](./bicep-cli.md#snapshot) command performs local-only testing by generating and comparing a normalized JSON representation of your infrastructure to catch unintended logic changes without requiring an Azure connection. For a comparison, see [Comparison snapshot vs what-if](./bicep-cli.md#validate-changes).
21
19
22
20
You can use the what-if operation with [Visual Studio Code](./deploy-visual-studio-code.md#deployment-pane), Azure PowerShell, Azure CLI, or REST API operations. What-if is supported for resource group, subscription, management group, and tenant level deployments.
0 commit comments