Skip to content

Commit 63aaeca

Browse files
committed
update
1 parent 3b302ae commit 63aaeca

3 files changed

Lines changed: 34 additions & 15 deletions

File tree

articles/azure-resource-manager/bicep/bicep-cli.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -710,15 +710,45 @@ bicep snapshot --mode validate <bicep-param-file>
710710

711711
---
712712

713-
The following screenshot shows a sample output:
713+
A sample output looks like:
714714

715-
:::image type="content" source="./media/bicep-cli/bicep-cli-snapshot-validate-output.png" alt-text="Screenshot of Bicep CLI snapshot command validate output.":::
715+
```
716+
PS C:\bicep> bicep snapshot --mode validate main.bicepparam
717+
Snapshot validation failed. Expected no changes, but found the following:
718+
719+
Scope: <unknown>
720+
721+
~ [format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Storage/storageAccounts/stmyappstorage001', subscription().subscriptionId, resourceGroup().name)]
722+
~ apiVersion: "2025-01-01" => "2025-06-01"
723+
~ sku.name: "Standard_LRS" => "Standard_GRS"
724+
```
716725

717726
"Snapshot validation failed" indicates differences between the two snapshots.
718727

728+
Snapshot and What-if have these differences:
729+
730+
| Feature | `bicep snapshot` | `az deployment group what-if` |
731+
| :--- | :--- | :--- |
732+
| **Execution** | **Local only** (Offline) | **Cloud-based** (Online) |
733+
| **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+
719737
### Provide context
720738

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` |
722752

723753
#### [Bicep CLI](#tab/bicep-cli)
724754

@@ -736,15 +766,6 @@ bicep snapshot main.bicepparam \
736766

737767
---
738768

739-
### Comparison: Snapshot vs. What-if
740-
741-
| Feature | `bicep snapshot` | `az deployment group what-if` |
742-
| :--- | :--- | :--- |
743-
| **Execution** | **Local only** (Offline) | **Cloud-based** (Online) |
744-
| **Comparison** | Compares code vs. a saved file | Compares code vs. live Azure state |
745-
| **Speed** | Extremely fast | Slower (requires API calls) |
746-
| **Use Case** | Refactoring and logic testing | Final pre-deployment check |
747-
748769
## upgrade
749770

750771
The `upgrade` command updates your installed version with the latest version. This command is only available through the Azure CLI.

articles/azure-resource-manager/bicep/deploy-what-if.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ ms.custom:
1515

1616
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.
1717

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).
2119

2220
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.
2321

Binary file not shown.

0 commit comments

Comments
 (0)