New-AzManagementGroupDeployment

在管理群組建立部署

Syntax

New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateFile <String>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateParameterObject <Hashtable>
   -TemplateObject <Hashtable>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateParameterObject <Hashtable>
   -TemplateFile <String>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateParameterObject <Hashtable>
   -TemplateUri <String>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateParameterObject <Hashtable>
   -TemplateSpecId <String>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateParameterFile <String>
   -TemplateObject <Hashtable>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateParameterFile <String>
   -TemplateFile <String>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateParameterFile <String>
   -TemplateUri <String>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateParameterFile <String>
   -TemplateSpecId <String>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateParameterFile <String>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateParameterUri <String>
   -TemplateObject <Hashtable>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateParameterUri <String>
   -TemplateFile <String>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateParameterUri <String>
   -TemplateUri <String>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateParameterUri <String>
   -TemplateSpecId <String>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateObject <Hashtable>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateUri <String>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzManagementGroupDeployment
   [-Name <String>]
   -ManagementGroupId <String>
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-Tag <Hashtable>]
   [-WhatIfResultFormat <WhatIfResultFormat>]
   [-WhatIfExcludeChangeType <String[]>]
   [-ProceedIfNoChange]
   [-AsJob]
   [-QueryString <String>]
   -TemplateSpecId <String>
   [-SkipTemplateParameterPrompt]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

New-AzManagementGroupDeployment Cmdlet 會在管理群組中新增部署。

若要在管理群組新增部署,請指定管理群組、位置和範本。 位置會告訴 Azure Resource Manager 儲存部署數據的位置。 範本是 JSON 字串,其中包含要部署的個別資源。 此範本包含必要資源和可設定屬性值的參數佔位元元,例如名稱和大小。

若要使用自定義範本進行部署,請指定 TemplateFile 參數或 TemplateUri 參數。 每個範本都有可設定屬性的參數。 若要指定範本參數的值,請指定 TemplateParameterFile 參數或 TemplateParameterObject 參數。 或者,您可以在指定範本時,使用動態新增至命令的範本參數。 若要使用動態參數,請在命令提示字元中輸入它們,或輸入減號 (-) 來指出參數,並使用 Tab 鍵來迴圈查看可用的參數。 您在命令提示字元輸入的樣本參數值優先於範本參數物件或檔案中的值。

若要將資源新增至資源群組,請使用 New-AzResourceGroupDeployment ,以在資源群組建立部署。 若要將資源新增至訂用帳戶,請使用 New-AzSubscriptionDeployment ,以在訂用帳戶範圍建立部署,以部署訂用帳戶層級資源。 若要在租使用者範圍新增資源,請使用 New-AzTenantDeployment ,以在租用戶範圍建立部署。

範例

範例 1:使用自定義範本和參數檔案來建立部署

New-AzManagementGroupDeployment -ManagementGroupId "myMG" -Location "West US" -TemplateFile "D:\Azure\Templates\OrgSetup.json" -TemplateParameterFile "D:\Azure\Templates\OrgParms.json" -Tag @{"key1"="value1"; "key2"="value2";}

此命令會使用自定義範本和磁碟上的範本檔案,搭配定義的tags參數,在管理群組 「myMG」 上建立新的部署。 此命令會 使用TemplateFile 參數來指定範本和 TemplateParameterFile 參數,以指定包含參數和參數值的檔案。

範例 2:使用 URI 和 SAS 令牌部署儲存在非公用記憶體帳戶中的範本

New-AzManagementGroupDeployment -ManagementGroupId "myMG" -Location "West US" -TemplateUri "https://example.com/example.json" -QueryString "foo"

此命令會使用TemplateUri中不是公用的範本來建立新的部署,而且需要令牌參數才能存取會使用QueryString參數所提供的令牌參數。 執行此命令會使用url https://example.com/example.json?foo有效地存取範本。 如果您想要在記憶體帳戶中使用範本,請藉由提供 SAS 令牌作為 QueryString,即可使用此選項

範例 3:使用自定義範本物件和參數檔案來建立部署

$TemplateFileText = [System.IO.File]::ReadAllText("D:\Azure\Templates\OrgSetup.json")
$TemplateObject = ConvertFrom-Json $TemplateFileText -AsHashtable
New-AzManagementGroupDeployment -ManagementGroupId "myMG" -Location "West US" -TemplateObject $TemplateObject -TemplateParameterFile "D:\Azure\Templates\OrgParams.json"

此命令會在管理群組 「myMG」 上使用自訂範本和已轉換成記憶體中哈希表之磁碟上的範本檔案,在管理群組 「myMG」 上建立新的部署。 前兩個命令會讀取磁碟上範本檔案的文字,並將其轉換為記憶體內部哈希表。 最後一個命令會 使用 TemplateObject 參數來指定這個哈希表和 TemplateParameterFile 參數,以指定包含參數和參數值的檔案。

範例 4:使用 .bicepparam 檔案建立部署

New-AzManagementGroupDeployment -ManagementGroupId "myMG" -Location "West US" -TemplateParameterFile "./parameters.bicepparam"

此命令會使用磁碟上的 .bicepparam 檔案,在管理群組範圍中建立新的部署。 此命令會使用 TemplateParameterFile 參數來指定 .bicepparam 檔案。

參數

-AsJob

在背景執行 Cmdlet

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

執行 Cmdlet 之前先提示您確認。

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

用於與 Azure 通訊的認證、帳戶、租用戶和訂用帳戶。

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DeploymentDebugLogLevel

部署偵錯記錄層級。

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Location

儲存部署數據的位置。

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ManagementGroupId

管理群組標識碼。

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Name

要建立的部署名稱。 如果未指定,則會在提供範本檔案時預設為範本檔名;默認為提供樣板物件的目前時間,例如 「20131223140835」。。

Type:String
Aliases:DeploymentName
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Pre

設定時,表示 Cmdlet 在自動判斷要使用的版本時,應該使用發行前版本 API 版本。

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ProceedIfNoChange

請勿要求確認結果中是否有任何變更。 適用於設定 -Confirm 參數時。

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-QueryString

要與 TemplateUri 參數搭配使用的查詢字串(例如 SAS 令牌)。 會用於連結的範本

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SkipTemplateParameterPrompt

略過 PowerShell 動態參數處理,檢查提供的範本參數是否包含範本所使用的所有必要參數。 這項檢查會提示使用者提供遺漏參數的值,但提供 -SkipTemplateParameterPrompt 會忽略此提示,並在找不到參數時立即在範本中系結時發生錯誤。 針對非互動式腳本,您可以提供 -SkipTemplateParameterPrompt,以在不符合所有必要參數的情況下提供更好的錯誤訊息。

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Tag

要放在部署上的標記。

Type:Hashtable
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-TemplateFile

範本檔案的本機路徑。 支援的範本檔類型:json 和 bicep。

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-TemplateObject

表示範本的哈希表。

Type:Hashtable
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-TemplateParameterFile

要用於範本的參數檔案。

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-TemplateParameterObject

表示參數的哈希表。

Type:Hashtable
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-TemplateParameterUri

範本參數檔案的 URI。

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-TemplateSpecId

要部署之 templateSpec 的資源識別碼。

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-TemplateUri

範本檔案的 URI。

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

顯示執行 Cmdlet 後會發生的情況。 未執行 Cmdlet。

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIfExcludeChangeType

要從 What-If 結果中排除的逗號分隔資源變更類型。 適用於設定 -WhatIf 或 -Confirm 參數時。

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIfResultFormat

What-If 結果格式。 適用於設定 -WhatIf 或 -Confirm 參數時。

Type:WhatIfResultFormat
Accepted values:ResourceIdOnly, FullResourcePayloads
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

輸入

Hashtable

String

輸出

PSDeployment