New-AzResourceGroupDeployment
將 Azure 部署加入資源群組。
Syntax
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateFile <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateParameterObject <Hashtable>
-TemplateObject <Hashtable>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateParameterObject <Hashtable>
-TemplateFile <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateParameterObject <Hashtable>
-TemplateUri <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateParameterObject <Hashtable>
-TemplateSpecId <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateParameterFile <String>
-TemplateObject <Hashtable>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateParameterFile <String>
-TemplateFile <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateParameterFile <String>
-TemplateUri <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateParameterFile <String>
-TemplateSpecId <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateParameterUri <String>
-TemplateObject <Hashtable>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateParameterUri <String>
-TemplateFile <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateParameterUri <String>
-TemplateUri <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateParameterUri <String>
-TemplateSpecId <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateObject <Hashtable>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateUri <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-ProceedIfNoChange]
[-AsJob]
[-QueryString <String>]
-TemplateSpecId <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
New-AzResourceGroupDeployment Cmdlet 會將部署新增至現有的資源群組。 這包括部署所需的資源。 Azure 資源是使用者管理的 Azure 實體,例如資料庫伺服器、資料庫、網站、虛擬機器或儲存體帳戶。 Azure 資源群組是部署為單位的 Azure 資源集合,例如財務網站所需的網站、資料庫伺服器和資料庫。 資源群組部署會使用範本將資源新增至資源群組,並加以發佈,使其可在 Azure 中使用。 若要在不使用範本的情況下將資源新增至資源群組,請使用 New-AzResource Cmdlet。 若要新增資源群組部署,請指定現有資源群組和資源群組範本的名稱。 資源群組範本是 JSON 字串,代表複雜雲端式服務的資源群組,例如入口網站。 此範本包含必要資源和可設定屬性值的參數預留位置,例如名稱和大小。 您可以在 Azure 範本資源庫中找到許多範本,也可以建立自己的範本。 若要使用自訂範本來建立資源群組,請指定 TemplateFile 參數或 TemplateUri 參數。 每個範本都有可設定屬性的參數。 若要指定範本參數的值,請指定 TemplateParameterFile 參數或 TemplateParameterObject 參數。 或者,您可以在指定範本時,使用動態新增至命令的範本參數。 若要使用動態參數,請在命令提示字元中輸入它們,或輸入減號 (-) 來指出參數,並使用 Tab 鍵迴圈查看可用的參數。 您在命令提示字元輸入的範本參數值優先于範本參數物件或檔案中的值。
範例
範例 1:使用自訂範本和參數檔案來建立部署
New-AzResourceGroupDeployment -ResourceGroupName "ContosoEngineering" -TemplateFile "D:\Azure\Templates\EngineeringSite.json" -TemplateParameterFile "D:\Azure\Templates\EngSiteParms.json" -Tag @{"key1"="value1"; "key2"="value2";}
此命令會使用自訂範本和磁片上的範本檔案,以及已定義的 tags 參數來建立新的部署。 此命令會使用 TemplateFile 參數來指定範本和 TemplateParameterFile 參數,以指定包含參數和參數值的檔案。
範例 2:使用自訂範本物件和參數檔案來建立部署
$TemplateFileText = [System.IO.File]::ReadAllText("D:\Azure\Templates\EngineeringSite.json")
$TemplateObject = ConvertFrom-Json $TemplateFileText -AsHashtable
New-AzResourceGroupDeployment -ResourceGroupName "ContosoEngineering" -TemplateObject $TemplateObject -TemplateParameterFile "D:\Azure\Templates\EngSiteParams.json"
此命令會使用已轉換成記憶體內部雜湊表之磁片上的自訂和範本檔案,建立新的部署。 前兩個命令會讀取磁片上範本檔案的文字,並將其轉換成記憶體內部雜湊表。 最後一個命令會使用 TemplateObject 參數來指定雜湊表和 TemplateParameterFile 參數,以指定包含參數和參數值的檔案。
範例 3
將 Azure 部署加入資源群組。 自動產生的 ()
New-AzResourceGroupDeployment -DeploymentDebugLogLevel RequestContent -Name mynewstorageaccount -ResourceGroupName 'ContosoEngineering' -TemplateFile 'D:\Azure\Templates\EngineeringSite.json' -TemplateParameterObject <Hashtable>
範例 4:使用 URI 和 SAS 權杖部署儲存在非公用儲存體帳戶中的範本
New-AzResourceGroupDeployment -ResourceGroupName "RGName" -TemplateUri "https://example.com/example.json" -QueryString "foo"
此命令會使用 TemplateUri 中的範本建立新的部署,此範本不是公用的,而且需要使用 QueryString 參數來存取權杖參數。
執行此命令會使用 url https://example.com/example.json?foo
有效地存取範本。
如果您想要在儲存體帳戶中使用範本,請提供 SAS 權杖作為 QueryString,即可使用此方式
參數
-AsJob
在背景執行 Cmdlet
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Confirm
在執行 Cmdlet 前提示您確認。
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DefaultProfile
用來與 azure 通訊的認證、帳戶、租使用者和訂用帳戶
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DeploymentDebugLogLevel
指定偵錯記錄層級。 此參數可接受的值為:
- RequestContent
- ResponseContent
- 全部
- 無
Type: | String |
Accepted values: | RequestContent, ResponseContent, All, None |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Force
強制執行命令而不要求使用者確認。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Mode
指定部署模式。 此參數可接受的值為:
- 完成:在完整模式中,Resource Manager會刪除存在於資源群組中但未在範本中指定的資源。
- 累加:在累加模式中,Resource Manager保留存在於資源群組中但未在範本中指定的未變更資源。
Type: | DeploymentMode |
Accepted values: | Incremental, Complete |
Position: | Named |
Default value: | Incremental |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Name
要建立的部署名稱。 如果未指定,則會在提供範本檔案時預設為範本檔案名;預設為提供範本物件時的目前時間,例如 「20131223140835」。
Type: | String |
Aliases: | DeploymentName |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Pre
指出此 Cmdlet 會在自動判斷要使用的版本時,考慮發行前版本的 API 版本。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ProceedIfNoChange
如果What-If結果中沒有任何變更,請勿要求確認。 適用于設定 -Confirm 參數時。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-QueryString
例如,查詢字串 (SAS 權杖) 與 TemplateUri 參數搭配使用。 如果是連結的範本,則會使用
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ResourceGroupName
指定要部署的資源組名。
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-RollBackDeploymentName
如果使用 -RollbackToLastDeployment,則不應該使用資源群組中具有指定名稱的成功部署。
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-RollbackToLastDeployment
如果使用 -RollBackDeploymentName,則不應該復原至資源群組中最後一次成功的部署。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-SkipTemplateParameterPrompt
略過 PowerShell 動態參數處理,以檢查所提供的範本參數是否包含範本所使用的所有必要參數。 這項檢查會提示使用者提供遺漏參數的值,但提供 -SkipTemplateParameterPrompt 將會忽略此提示,並在找不到參數未在範本中系結時立即發生錯誤。 針對非互動式腳本,您可以提供 -SkipTemplateParameterPrompt,以在不符合所有必要參數的情況下提供更好的錯誤訊息。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Tag
要放在部署上的標記。
Type: | Hashtable |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-TemplateFile
指定自訂範本檔案的完整路徑。 支援的範本檔案類型:json 和 bicep。
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-TemplateObject
代表範本的雜湊表。
Type: | Hashtable |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-TemplateParameterFile
指定 JSON 檔案的完整路徑,其中包含範本參數的名稱和值。 如果範本有參數,您必須使用 TemplateParameterFile 參數或 TemplateParameterObject 參數來指定參數值。 當您指定範本時,範本參數會動態新增至命令。 若要使用動態參數,請輸入減號 (-) 來指出參數名稱,然後使用 Tab 鍵迴圈查看可用的參數。
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-TemplateParameterObject
指定範本參數名稱和值的雜湊表。
如需Windows PowerShell中雜湊表的說明,請輸入 Get-Help about_Hash_Tables
。
如果範本有參數,您必須指定參數值。
當您指定範本時,範本參數會動態新增至命令。
Type: | Hashtable |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-TemplateParameterUri
指定範本參數檔案的 URI。 使用 TemplateParameterUri 時,會忽略您使用的任何動態參數。 若要使用動態參數,您必須改用 TemplateParameterFile 參數
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-TemplateSpecId
要部署之 templateSpec 的資源識別碼。
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-TemplateUri
指定自訂範本檔案的 URI。
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-WhatIf
顯示執行 Cmdlet 後會發生的情況。 Cmdlet 並不會執行。
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIfExcludeChangeType
要從結果中排除的逗號分隔資源變更類型What-If。 當設定 -WhatIf 或 -Confirm 參數時適用。
Type: | String[] |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIfResultFormat
What-If結果格式。
Type: | WhatIfResultFormat |
Accepted values: | ResourceIdOnly, FullResourcePayloads |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
輸入
輸出
相關連結
意見反應
提交並檢視相關的意見反應