新的 Azure PowerShell Az 模組簡介Introducing the new Azure PowerShell Az module

從 2018 年 12 月開始,Azure PowerShell Az 模組已正式運作,並已成為與 Azure 互動時的預期 PowerShell 模組。Starting in December 2018, the Azure PowerShell Az module is in general release and now the intended PowerShell module for interacting with Azure. Az 可提供較短的命令、改進的穩定性和跨平台支援。Az offers shorter commands, improved stability, and cross-platform support. Az 也提供功能同位以及從 AzureRM 遷移的簡單路徑。Az also offers feature parity and an easy migration path from AzureRM.

透過 Az 模組,Azure PowerShell 現已相容於 Windows 上的 PowerShell 5.1 以及所有支援平台上的 PowerShell Core 6.x 和更新版本,包括 Windows、macOS 和 Linux。With the Az module, Azure PowerShell is now compatible with PowerShell 5.1 on Windows and PowerShell Core 6.x and later on all supported platforms - including Windows, macOS, and Linux.

Az 是新模組,因此版本已重設為 1.0.0。Az is a new module, so the version has been reset to 1.0.0.

為何推出新模組?Why a new module?

重大更新可能不便執行,因此我們必須讓您了解我們為何決定導入一組附有新 Cmdlet 的新模組,供您從 PowerShell 與 Azure 互動。Major updates can be inconvenient, so it's important that we let you know why the decision was made to introduce a new set of modules, with new cmdlets, for interacting with Azure from PowerShell.

最顯著而重要的變更是,隨著 PowerShell Core 6.x 的導入 (以 .NET Standard 程式庫為基礎),PowerShell 已成為跨平台產品。The biggest and most important change is that PowerShell has been a cross-platform product since the introduction of PowerShell Core 6.x, based on the .NET Standard library. 我們致力於將 Azure 支援導入所有平台,而這意味著 Azure PowerShell 模組必須進行更新,以使用 .NET Standard 並且與 PowerShell Core 相容。We're committed to bringing Azure support to all platforms, which means that the Azure PowerShell modules needed to be updated to use .NET Standard and be compatible with PowerShell Core. 我們決定不以現有的 AzureRM 模組導入複雜的變更來加入這項支援,而是建立了 Az 模組。Rather than taking the existing AzureRM module and introduce complex changes to add this support, the Az module was created.

建立新模組也讓我們的工程師有機會可將 Cmdlet 和模組的設計與命名趨於一致。Creating a new module also gave our engineers the opportunity to make the design and naming of cmdlets and modules consistent. 現在,所有模組皆以 Az. 前置詞開頭,且 Cmdlet 全都採用_動詞_-Az_名詞_的格式。All modules now start with the Az. prefix and cmdlets all use the Verb-AzNoun form. 過去,Cmdlet 名稱不僅較長,這些名稱也有不一致的情況。Previously, cmdlet names were not only longer, there were inconsistencies in cmdlet names.

模組數目也已減少:某些與相同服務搭配運作的模組已彙整在一起,且管理平面和資料平面 Cmdlet 現在也全都包含在其服務的單一模組中。The number of modules was also reduced: Some modules which worked with the same services have been rolled together, and management plane and data plane cmdlets are now contained all within single modules for their services. 對於手動管理相依性和匯入的使用者,其作業將可因此而簡化。For those of you who manually manage dependencies and imports, this makes things much simpler.

藉由進行這些需要建置新 Azure PowerShell 模組的重要變更,小組成員努力促使 Azure 與 PowerShell Cmdlet 的搭配使用比以往更簡便,並且可在更多平台上使用。By making these important changes that required building a new Azure PowerShell module, the team has committed to making it easier than ever, and on more platforms than previously possible, to use Azure with PowerShell cmdlets.

升級至 AzUpgrade to Az

為了運用 PowerShell 中的最新 Azure 功能,您應盡速移轉至 Az 模組。To keep up with the latest Azure features in PowerShell, you should migrate to the Az module as soon as possible. 若您尚未準備好要安裝 Az 模組來取代 AzureRM,您可以透過下列方式試用 Az:If you're not ready to install the Az module as a replacement for AzureRM, you have a couple of options available to experiment with Az:

  • PowerShell 環境中使用 Azure Cloud ShellUse a PowerShell environment with Azure Cloud Shell. Azure Cloud Shell 是一種以瀏覽器為基礎的殼層環境,隨附有已安裝的 Az 模組,且已啟用 Enable-AzureRM 相容性別名。Azure Cloud Shell is a browser-based shell environment which comes with the Az module installed and Enable-AzureRM compatibility aliases enabled.
  • 保留隨著 PowerShell 5.1 for Windows 而安裝的 AzureRM 模組,但安裝適用於 PowerShell Core 6.x 或更新版本的 Az 模組。Keep the AzureRM module installed with PowerShell 5.1 for Windows, but install the Az module for PowerShell Core 6.x or later. PowerShell 5.1 for Windows 和 PowerShell Core 分別使用不同的模組集合。PowerShell 5.1 for Windows and PowerShell Core use separate collections of modules. 請依照指示從 PowerShell Core 終端機安裝 PowerShell Core,然後安裝 Az 模組Follow the instructions to install PowerShell Core and then install the Az module from a PowerShell Core terminal.

若要從現有的 AzureRM 安裝升級:To upgrade from an existing AzureRM install:

  1. 將 Azure PowerShell AzureRM 模組解除安裝Uninstall the Azure PowerShell AzureRM module
  2. 安裝 Azure PowerShell Az 模組Install the Azure PowerShell Az module
  3. 選擇性:當您熟悉新的命令集時,請使用 Enable-AzureRMAlias 啟用相容性模式來新增 AzureRM Cmdlet 的別名。OPTIONAL: Enable compatibility mode to add aliases for AzureRM cmdlets with Enable-AzureRMAlias while you become familiar with the new command set. 如需詳細資訊,請參閱下一節或開始從 AzureRM 移轉至 AzSee the next section or Start migration from AzureRM to Az for more details.

將現有指令碼遷移至 AzMigrate existing scripts to Az

新的 Cmdlet 名稱已設計為易於了解。The new cmdlet names have been designed to be easy to learn. 請在 Cmdlet 名稱中使用 Az,而非使用 AzureRmAzureInstead of using AzureRm or Azure in cmdlet names, use Az. 例如,舊命令 New-AzureRMVm 已變成 New-AzVmFor example, the old command New-AzureRMVm has become New-AzVm. 不過,移轉不僅只是熟悉新的 Cmdlet 名稱:此外還有重新命名的模組、參數和其他重要變更。Migration is more than just becoming familiar with the new cmdlet names, though: There are renamed modules, parameters, and other important changes.

為了協助您執行從 AzureRM 移轉至 Az 的程序,我們提供了一些資源:To help you with the process of migration from AzureRM to Az, we've got a number of resources:

當您處理新語法的更新時,Az 模組有相容性模式可協助您使用現有指令碼。The Az module has a compatibility mode to help you use existing scripts while you update to the new syntax. Enable-AzureRmAlias Cmdlet 會透過別名啟用相容性模式,讓您在最少的修改下使用現有的指令碼,同時完成完整移轉至 Az 的作業。The Enable-AzureRmAlias cmdlet enables a compatibility mode through aliases, to allow you to use existing scripts with minimal modification while working towards a full migration to Az.

重要

即使 Cmdlet 名稱已有別名,但 Az Cmdlet 仍可能有新的 (或重新命名的) 參數或已變更的傳回值。Even though the cmdlet names are aliased, there may still be new (or renamed) parameters or changed return values for the Az cmdlets. 請不要誤以為啟用別名就能完成移轉。Don't expect enabling aliases to take care of the migration for you! 請參閱完整重大變更清單,找出您的指令碼可能需要更新之處。See the full breaking changes list to find where your scripts may require updates.

對 AzureRM 的持續支援Continued support for AzureRM

現有 AzureRM 模組不會再收到新的 Cmdlet 或功能。The existing AzureRM module will no longer receive new cmdlets or features. 不過,我們仍會正式維護 AzureRM,且最晚會在 2020 年 12 月之前提供錯誤修正。However, AzureRM is still officially maintained and will get bug fixes up through at least December 2020.

如果您對 Az 模組的功能完整性、是否經過測試或可供實際運作之用有所疑慮:過去著力於 AzureRM 的所有工程工作現在都已轉移至 Az,包括盡可能重複使用現有模組的程式碼,以及經由廣泛的測試達到新模組的功能相容性。If you have concerns about whether or not the Az module is as fully-featured, tested, or production ready: All of the engineering work that went into AzureRM has now been focused on Az, including as much code reuse of the existing modules as was possible, and extensive testing to make the new modules feature-compatible. 是否移至 Az 應完全取決於組織的排程,而無須等候特定功能出現。Moving onto Az should be influenced by your organization's schedule alone, without needing to wait on specific features to appear.