# Bicep Operations Deploy Azure infrastructure using Bicep templates. ## Operations ### Bicep.DeployToResourceGroup Deploy a Bicep template to a resource group. Returns a `BicepDeployment` with typed access to outputs via `deployment.Output("name")`. ```csharp var deployment = Bicep.DeployToResourceGroup("my-rg", "./infra/main.bicep"); var deployment = Bicep.DeployToResourceGroup("my-rg", "./main.bicep", o => o .WithParameterFile("./params.json") .WithDeploymentSlot("staging")); Ef.DatabaseUpdate(db, deployment.Output("sqlConnectionString")); ``` ### Bicep.DeployToSubscription Deploy a Bicep template at subscription scope. Returns a `BicepDeployment` with typed access to outputs via `deployment.Output("name")`. ```csharp var deployment = Bicep.DeployToSubscription("eastus", "./infra/sub.bicep"); var deployment = Bicep.DeployToSubscription("eastus", "./sub.bicep", o => o .WithParameter("environment", "prod")); var resourceGroup = deployment.Output("resourceGroupName"); ``` ### Bicep.WhatIf Preview what would be deployed (what-if analysis). ```csharp Bicep.WhatIf("my-rg", "./infra/main.bicep"); Bicep.WhatIf("my-rg", "./main.bicep", o => o.WithParameterFile("./params.json")); ``` ### Bicep.Build Compile a Bicep file to ARM JSON template. ```csharp Bicep.Build("./infra/main.bicep"); Bicep.Build("./main.bicep", "./output/main.json"); ``` ## Example Deploy infrastructure and use outputs in subsequent steps. ```csharp // Preview changes first Bicep.WhatIf("my-app-rg", "./infra/main.bicep", o => o .WithParameterFile("./infra/params.prod.json")); // Deploy - returns BicepDeployment with typed output access var deployment = Bicep.DeployToResourceGroup("my-app-rg", "./infra/main.bicep", o => o .WithParameterFile("./infra/params.prod.json")); // Pass deployment outputs to other operations Ef.DatabaseUpdate(DbContext, deployment.Output("sqlConnectionString")); // Build Bicep to ARM for validation Bicep.Build("./infra/main.bicep", "./artifacts/main.json"); ``` ## Options Reference ### Bicep.DeployToResourceGroup / DeployToSubscription / WhatIf Options | Option | Description | |--------|-------------| | `WithName(string)` | Custom deployment name. Defaults to the template filename. Useful for tracking deployments in Azure Portal activity log. | | `WithParameterFile(string)` | Path to parameters file. Supports both JSON parameter files (.json) and Bicep parameter files (.bicepparam). | | `WithParameter(name, value)` | Add an inline parameter value. Overrides values from parameter files. Can be called multiple times for multiple parameters. | | `WithMode(DeploymentMode)` | Deployment mode: `DeploymentMode.Incremental` (default) adds/updates resources but doesn't delete missing ones. `DeploymentMode.Complete` deletes resources not in the template (use with caution). | | `WithDeploymentSlot(string)` | Deployment slot for App Service resources. Used when deploying to a specific slot (e.g., "staging") rather than production. |