共用方式為


New-AzureRmDeployment

建立部署

警告

自 2024 年 2 月 29 日起,AzureRM PowerShell 模組已正式淘汰。 建議使用者從 AzureRM 遷移至 Az PowerShell 模組,以確保持續支援和更新。

雖然 AzureRM 模組可能仍可運作,但不再維護或支援它,但會根據用戶的判斷權和風險放置任何繼續使用。 如需轉換至 Az 模組的指引,請參閱我們的 移轉資源

語法

New-AzureRmDeployment
   [-Name <String>]
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-AsJob]
   -TemplateFile <String>
   [-ApiVersion <String>]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmDeployment
   [-Name <String>]
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-AsJob]
   -TemplateParameterObject <Hashtable>
   -TemplateFile <String>
   [-ApiVersion <String>]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmDeployment
   [-Name <String>]
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-AsJob]
   -TemplateParameterObject <Hashtable>
   -TemplateUri <String>
   [-ApiVersion <String>]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmDeployment
   [-Name <String>]
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-AsJob]
   -TemplateParameterFile <String>
   -TemplateFile <String>
   [-ApiVersion <String>]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmDeployment
   [-Name <String>]
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-AsJob]
   -TemplateParameterFile <String>
   -TemplateUri <String>
   [-ApiVersion <String>]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmDeployment
   [-Name <String>]
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-AsJob]
   -TemplateParameterUri <String>
   -TemplateFile <String>
   [-ApiVersion <String>]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmDeployment
   [-Name <String>]
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-AsJob]
   -TemplateParameterUri <String>
   -TemplateUri <String>
   [-ApiVersion <String>]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmDeployment
   [-Name <String>]
   -Location <String>
   [-DeploymentDebugLogLevel <String>]
   [-AsJob]
   -TemplateUri <String>
   [-ApiVersion <String>]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

New-AzureRmDeployment Cmdlet 會在目前的訂用帳戶範圍中新增部署。 這包括部署所需的資源。

Azure 資源是使用者管理的 Azure 實體。 資源可以存在於資源群組中,例如資料庫伺服器、資料庫、網站、虛擬機或 儲存體 帳戶。 或者,它可以是訂用帳戶層級資源,例如角色定義、原則定義等。

若要將資源新增至資源群組,請使用 New-AzureRmDeployment ,以在資源群組建立部署。 New-AzureRmDeployment Cmdlet 會在目前的訂用帳戶範圍建立部署,以部署訂用帳戶層級資源。

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

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

範例

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

PS C:\>New-AzureRmDeployment -Location "West US" -TemplateFile "D:\Azure\Templates\EngineeringSite.json" -TemplateParameterFile "D:\Azure\Templates\EngSiteParms.json" -TemplateVersion "2.1"

此命令會使用自定義範本和磁碟上的範本檔案,在目前的訂用帳戶範圍建立新的部署。 此命令會 使用TemplateFile 參數來指定範本和 TemplateParameterFile 參數,以指定包含參數和參數值的檔案。 它會使用 TemplateVersion 參數來指定範本的版本。

參數

-ApiVersion

設定時,表示要使用的資源提供者 API 版本。 如果未指定,API 版本會自動判斷為最新的可用版本。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-AsJob

在背景執行 Cmdlet

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Confirm

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

類型:SwitchParameter
別名:cf
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-DefaultProfile

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

類型:IAzureContextContainer
別名:AzureRmContext, AzureCredential
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-DeploymentDebugLogLevel

部署偵錯記錄層級。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Location

儲存部署數據的位置。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-Name

要建立的部署名稱。 只有在使用範本時才有效。 使用範本時,如果使用者未指定部署名稱,請使用目前的時間,例如 「20131223140835」。。

類型:String
別名:DeploymentName
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Pre

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

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-TemplateFile

範本檔案的本機路徑。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-TemplateParameterFile

具有範本參數的檔案。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-TemplateParameterObject

表示參數的哈希表。

類型:Hashtable
Position:Named
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-TemplateParameterUri

範本參數檔案的 URI。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-TemplateUri

範本檔案的 URI。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-WhatIf

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

類型:SwitchParameter
別名:wi
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

輸入

String

System.Collections.Hashtable

輸出

PSDeployment