New-CafDeployment
Deploys Azure resources from a bicep file within the current azcontext context by using an automatically created ops service principal.
Syntax
New-CafDeployment
[-DeploymentDebugLogLevel <string>]
[-Location <string>]
[-PostScriptFile <string>]
[-PreScriptFile <string>]
[-ResourceGroupLocation <string>]
[-ResourceGroupName <string>]
[-Stage <string>]
[-ServicePrincipalScope <string>]
[-ServicePrincipalType <string>]
[-SpecificDeploymentFile <string>]
[-SpecificParameterFile <string>]
[-WhatIfExcludeChangeType <string>]
[-WhatIfResultFormat <string>]
[-PerformPreDeploymentInCurrentScope]
[-WhatIf]
Description
Gets the SubscriptionId from the .azcontext file. It uses this ID and retrieves the ops service principal which has an Owner role assignment on the subscription scope.
This service principal is then used as context for the deployment. The command has to be run in the project folder which contains the main.bicep file or the SpecificDeploymentFile must be provided.
Example
New-CafDeployment
-Stage "int"
-ServicePrincipalScope "ManagementGroup"
Parameter
-DeploymentDebugLogLevel Defines the verboseness of the debug output.
| Property | Value |
|---|---|
| Type: | string |
| Allowed values: | ["All", "None", "RequestContent", "ResponseContent"] |
| Default value: | "None" |
| Required: | False |
-Location Overrides the Azure deployment location. When not provided, the location is read from the parameter file.
| Property | Value |
|---|---|
| Type: | string |
| Default value: | "" |
| Required: | False |
-PostScriptFile Optional path to a script which can be executed after the actual deployment happens.
| Property | Value |
|---|---|
| Type: | string |
| Default value: | "" |
| Required: | False |
-PreScriptFile
Optional path to a script which can be executed before the actual deployment happens. The script must take at least Stage, ParameterFile and WhatIf without any other mandatory parameters in.
| Property | Value |
|---|---|
| Type: | string |
| Default value: | "" |
| Required: | False |
-ResourceGroupLocation
The name of the Azure region where to deploy to if the BICEP target scope is set to resourceGroup.
| Property | Value |
|---|---|
| Type: | string |
| Default value: | None |
| Required: | False |
-ResourceGroupName
The name of the target resource group if the BICEP target scope is set to resourceGroup.
| Property | Value |
|---|---|
| Type: | string |
| Default value: | None |
| Required: | False |
-Stage Specifies the stage of the deployment.
| Property | Value |
|---|---|
| Type: | string |
| Allowed values: | ["none", "int", "test", "prod", ""] |
| Default value: | "none" |
| Required: | False |
-ServicePrincipalScope Specifies the scope of service principal to use.
| Property | Value |
|---|---|
| Type: | string |
| Allowed values: | ["Subscription", "ManagementGroup"] |
| Default value: | "Subscription" |
| Required: | False |
-ServicePrincipalType Specifies the type of service principal to use.
| Property | Value |
|---|---|
| Type: | string |
| Allowed values: | ["deploy", "ops"] |
| Default value: | "deploy" |
| Required: | False |
-SpecificDeploymentFile
Specifies the name of the BICEP file to use. If not set, the command will search for a main.bicep file in the current working directory.
If the file is not found, an error will be thrown.
| Property | Value |
|---|---|
| Type: | string |
| Default value: | None |
| Required: | False |
-SpecificParameterFile
Specifies the name of the parameter file to use. If not set, the command will search for a parameter file in the following order: [stage].bicepparam, parameters.[stage].bicepparam, parameters/[stage].bicepparam, [stage].json, parameters.[stage].json, parameters/[stage].json.
If none of these files are found, an error will be thrown.
| Property | Value |
|---|---|
| Type: | string |
| Default value: | None |
| Required: | False |
-WhatIfExcludeChangeType
Comma-separated list of resource change types to exclude from WhatIf results. Only applies when -WhatIf is set.
| Property | Value |
|---|---|
| Type: | string |
| Allowed values: | ["Ignore", "NoChange", "Deploy", "Create", "Modify", "Delete", "None"] |
| Default value: | "None" |
| Required: | False |
-WhatIfResultFormat
Controls the output format of WhatIf results. Only applies when -WhatIf is set.
| Property | Value |
|---|---|
| Type: | string |
| Allowed values: | ["FullResourcePayloads", "ResourceIdOnly"] |
| Default value: | "FullResourcePayloads" |
| Required: | False |
-PerformPreDeploymentInCurrentScope
If set, the PreScriptFile will be executed in the current powershell session and not in the internally created one. This means it will use the identity which is in the current powershell session to access Azure and not the service principal inside the pre-script file.
| Property | Value |
|---|---|
| Type: | SwitchParameter |
| Default value: | False |
| Required: | False |
-WhatIf
If specified, the deployment is only simulated.
| Property | Value |
|---|---|
| Type: | SwitchParameter |
| Default value: | False |
| Required: | False |