Azure PowerShell Service Management モジュールのインストール

注意

このドキュメントで参照されているコマンドレットは、Service Management API を使用するレガシ Azure リソースを管理するためのものです。 Azure Resource Manager リソースを管理するためのコマンドレットについては、Az PowerShell モジュールを参照してください。

Azure PowerShell Service Management モジュールはロールアップ モジュールです。 Azure PowerShell Service Management モジュールをインストールすると、Service Management API を使用する従来の Azure リソースを管理するための一般提供モジュールがダウンロードされ、そのコマンドレットを使用できるようになります。

前提条件

重要

Azure PowerShell Service Management モジュールは、Windows PowerShell でのみ機能します。 PowerShell バージョン 6 以降に対応していないため、Linux または macOS では実行できません。

  • お使いの PowerShell のバージョンを確認するには、PowerShell から次のコマンドを実行します。

    $PSVersionTable.PSVersion
    
  • Windows PowerShell 5.1 に更新する

  • PowerShell スクリプトの実行をリモート署名済みまたは制限が緩い状態に設定します。

    • PowerShell 実行ポリシーを確認します。

      Get-ExecutionPolicy -List
      
    • PowerShell 実行ポリシーをリモート署名済みに設定します。

      Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
      

      実行ポリシーの詳細については、「about_Execution_Policies」を参照してください。

  • PowerShellGet for Windows PowerShell 5.1 の更新

インストール

Azure PowerShell Service Management モジュールをインストールするには、Install-Module コマンドレットを使用します。

Install-Module -Name Azure, Azure.Storage -Repository PSGallery -AllowClobber -Force

Azure PowerShell Service Management モジュールでは、Azure PowerShell Resource Manager モジュールと依存関係が共有されます。 Azure PowerShell Resource Manager モジュールをインストール済みの場合は、前のコマンドに示すように AllowClobber パラメーターが必要です。 これにより、共通する既存の依存コンポーネントを更新できます。 このパラメーターを指定しないと、モジュールのインストールは失敗します。

Azure PowerShell Service Management モジュールをインストールしたら、モジュールをインポートします。

Import-Module -Name Azure

サインイン

Azure PowerShell Service Management モジュールを使用してレガシ Azure リソースの管理を開始するには、PowerShell セッションを起動し、Add-AzureAccount を実行して Azure にサインインします。

Add-AzureAccount

Azure にログインすると、指定されたセッションのコンテキストが Azure PowerShell Service Management モジュールによって作成されます。 コンテキストには、そのセッション内のすべてのコマンドレットで使われる Azure 環境、アカウント、テナント、サブスクリプションが保持されています。

トラブルシューティング

"The specified module 'Azure.Storage' with version '4.3.0' was not loaded because no valid module file was found in any module directory." (モジュール ディレクトリに有効なモジュール ファイルが見つからなかったため、バージョン '4.3.0' の指定されたモジュール 'Azure.Storage' が読み込まれていませんでした) というエラーが表示された場合は、Azure.Storage PowerShell モジュールをインストールする必要があります。

Install-Module -Name Azure.Storage -Repository PSGallery -AllowClobber -Force

"The 'Install-Module' command was found in the module 'PowerShellGet', but the module could not be loaded." (モジュール 'PowerShellGet' で 'Install-Module' コマンドが見つかりましたが、モジュールを読み込めませんでした) というエラーが表示された場合は、PowerShell 実行ポリシーをリモート署名済みまたは制限の緩い状態に設定する必要があります。

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

関連項目

Azure PowerShell Service Management モジュールのコマンドの詳細については、コマンドレットのリファレンス ドキュメントを参照してください。