Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
New-AzDeployment
- Module:
- Az.Resources Module
Create a deployment at the current subscription scope.
Syntax
ByTemplateFileWithNoParameters (Default)
New-AzDeployment
-Location <String>
-TemplateFile <String>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTemplateObjectAndParameterObject
New-AzDeployment
-Location <String>
-TemplateParameterObject <Hashtable>
-TemplateObject <Hashtable>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTemplateFileAndParameterObject
New-AzDeployment
-Location <String>
-TemplateParameterObject <Hashtable>
-TemplateFile <String>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTemplateUriAndParameterObject
New-AzDeployment
-Location <String>
-TemplateParameterObject <Hashtable>
-TemplateUri <String>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTemplateSpecResourceIdAndParamsObject
New-AzDeployment
-Location <String>
-TemplateParameterObject <Hashtable>
-TemplateSpecId <String>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTemplateObjectAndParameterFile
New-AzDeployment
-Location <String>
-TemplateParameterFile <String>
-TemplateObject <Hashtable>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTemplateFileAndParameterFile
New-AzDeployment
-Location <String>
-TemplateParameterFile <String>
-TemplateFile <String>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTemplateUriAndParameterFile
New-AzDeployment
-Location <String>
-TemplateParameterFile <String>
-TemplateUri <String>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTemplateSpecResourceIdAndParams
New-AzDeployment
-Location <String>
-TemplateParameterFile <String>
-TemplateSpecId <String>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByParameterFileWithNoTemplate
New-AzDeployment
-Location <String>
-TemplateParameterFile <String>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTemplateObjectAndParameterUri
New-AzDeployment
-Location <String>
-TemplateParameterUri <String>
-TemplateObject <Hashtable>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTemplateFileAndParameterUri
New-AzDeployment
-Location <String>
-TemplateParameterUri <String>
-TemplateFile <String>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTemplateUriAndParameterUri
New-AzDeployment
-Location <String>
-TemplateParameterUri <String>
-TemplateUri <String>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTemplateSpecResourceIdAndParamsUri
New-AzDeployment
-Location <String>
-TemplateParameterUri <String>
-TemplateSpecId <String>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTemplateObjectWithNoParameters
New-AzDeployment
-Location <String>
-TemplateObject <Hashtable>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTemplateUriWithNoParameters
New-AzDeployment
-Location <String>
-TemplateUri <String>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTemplateSpecResourceId
New-AzDeployment
-Location <String>
-TemplateSpecId <String>
[-Name <String>]
[-DeploymentDebugLogLevel <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The New-AzDeployment cmdlet adds a deployment at the current subscription scope. This includes the resources that the deployment requires.
An Azure resource is a user-managed Azure entity. A resource can live in a resource group, like database server, database, website, virtual machine, or Storage account. Or, it can be a subscription level resource, like role definition, policy definition, etc.
To add resources to a resource group, use the New-AzResourceGroupDeployment which creates a deployment at a resource group. The New-AzDeployment cmdlet creates a deployment at the current subscription scope, which deploys subscription level resources.
To add a deployment at subscription, specify the location and a template. The location tells Azure Resource Manager where to store the deployment data. The template is a JSON string that contains individual resources to be deployed. The template includes parameter placeholders for required resources and configurable property values, such as names and sizes.
To use a custom template for the deployment, specify the TemplateFile parameter or TemplateUri parameter. Each template has parameters for configurable properties. To specify values for the template parameters, specify the TemplateParameterFile parameter or the TemplateParameterObject parameter. Alternatively, you can use the template parameters that are dynamically added to the command when you specify a template. To use dynamic parameters, type them at the command prompt, or type a minus sign (-) to indicate a parameter and use the Tab key to cycle through available parameters. Template parameter values that you enter at the command prompt take precedence over values in a template parameter object or file.
Examples
Example 1: Use a custom template and parameter file to create a deployment
New-AzDeployment -Location "West US" -TemplateFile "D:\Azure\Templates\EngineeringSite.json" -TemplateParameterFile "D:\Azure\Templates\EngSiteParms.json" -Tag @{"key1"="value1"; "key2"="value2";}
This command creates a new deployment at the current subscription scope by using a custom template and a template file on disk, with defined tags parameter. The command uses the TemplateFile parameter to specify the template and the TemplateParameterFile parameter to specify a file that contains parameters and parameter values.
Example 2: Deploy a template stored in a non public storage account using a uri and SAS token
New-AzDeployment -Location "West US" -TemplateUri "https://example.com/example.json" -QueryString "foo"
This command creates a new deployment using the template in TemplateUri which is not public and requires a token parameter to access which would be provided using the QueryString parameter.
Running this command effectively accesses the template using the url https://example.com/example.json?foo.
This can be used if you want to use a template in a storage account by providing the SAS token as the QueryString
Example 3: Use a custom template object and parameter file to create a deployment
$TemplateFileText = [System.IO.File]::ReadAllText("D:\Azure\Templates\EngineeringSite.json")
$TemplateObject = ConvertFrom-Json $TemplateFileText -AsHashtable
New-AzDeployment -Location "West US" -TemplateObject $TemplateObject -TemplateParameterFile "D:\Azure\Templates\EngSiteParams.json"
This command creates a new deployment at the current subscription scope by using a custom template and a template file on disk that has been converted to an in-memory hashtable. The first two commands read the text for the template file on disk and convert it to an in-memory hashtable. The last command uses the TemplateObject parameter to specify this hashtable and the TemplateParameterFile parameter to specify a file that contains parameters and parameter values.
Example 4: Use a .bicepparam file to create a deployment
New-AzDeployment -Location "West US" -TemplateParameterFile "./parameters.bicepparam"
This command creates a new deployment at the current subscription scope by using a .bicepparam file on disk. The command uses the TemplateParameterFile parameter to specify a .bicepparam file.
Parameters
-AsJob
Run cmdlet in the background
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | cf |
Parameter sets
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Parameter properties
| Type: | IAzureContextContainer |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | AzContext, AzureRmContext, AzureCredential |
Parameter sets
-DeploymentDebugLogLevel
The deployment debug log level.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Location
The location to store deployment data.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Name
The name of the deployment it's going to create. If not specified, defaults to the template file name when a template file is provided; defaults to the current time when a template object is provided, e.g. "20131223140835".
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | DeploymentName |
Parameter sets
-Pre
When set, indicates that the cmdlet should use pre-release API versions when automatically determining which version to use.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ProceedIfNoChange
Do not ask for confirmation if there is no changes in the What-If result. Applicable when the -Confirm switch is set.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-QueryString
The query string (for example, a SAS token) to be used with the TemplateUri parameter. Would be used in case of linked templates
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-SkipTemplateParameterPrompt
Skips the PowerShell dynamic parameter processing that checks if the provided template parameter contains all necessary parameters used by the template. This check would prompt the user to provide a value for the missing parameters, but providing the -SkipTemplateParameterPrompt will ignore this prompt and error out immediately if a parameter was found not to be bound in the template. For non-interactive scripts, -SkipTemplateParameterPrompt can be provided to provide a better error message in the case where not all required parameters are satisfied.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Tag
The tags to put on the deployment.
Parameter properties
| Type: | Hashtable |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-TemplateFile
Local path to the template file. Supported template file type: json and bicep.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-TemplateObject
A hash table which represents the template.
Parameter properties
| Type: | Hashtable |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-TemplateParameterFile
Parameter file to use for the template.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-TemplateParameterObject
A hash table which represents the parameters.
Parameter properties
| Type: | Hashtable |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-TemplateParameterUri
Uri to the template parameter file.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-TemplateSpecId
Resource ID of the templateSpec to be deployed.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-TemplateUri
Uri to the template file.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ValidationLevel
Sets the validation level for validate/what-if. ValidationLevel can be Template(Skips provider validation), Provider(Performs full validation), or ProviderNoRbac(Performs full validation using RBAC read checks instead of RBAC write checks for provider validation).
Parameter properties
| Type: | String |
| Default value: | None(Provider) |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | wi |
Parameter sets
-WhatIfExcludeChangeType
Comma-separated resource change types to be excluded from What-If results. Applicable when the -WhatIf or -Confirm switch is set.
Parameter properties
| Type: | String[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-WhatIfResultFormat
The What-If result format.
Parameter properties
| Type: | WhatIfResultFormat |
| Default value: | None |
| Accepted values: | ResourceIdOnly, FullResourcePayloads |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
Hashtable
String
Outputs
PSDeployment
Azure PowerShell
Feedback
Was this page helpful?
