PowerShellからAzureにログイン出来るようにしたのでメモとして残しておきます。
最新版PowerShellをダウンロード
GitHubで公開されているのでそこから最新版をダウンロードしてきます。
URLはこちら。
https://github.com/PowerShell/PowerShell/releases
下にスクロールしていくとwindows 64bit版があったのでこちらをダウンロードしました。
PowerShellからAzureにログイン
インストールしてPowerShellを立ち上げるとダウンロードしたバージョンであることが分かります。
PowerShell 7.5.0
PS C:\Users\user>
でもこのままではAzureにログインできません。
PS C:\Users\user> Connect-AzAccount
Connect-AzAccount: The term 'Connect-AzAccount' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Azureのモジュールをインストールする必要があるようです。
PS C:\Users\user> install-Module -Name AZ
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet.
Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A #今回は全てのモジュールをインストールするため【A】を入力。
モジュールのインストールが完了すればAzureにログインする準備は出来ました。
今回はDeviceCodeを使ってAzureに接続してみます。
PS C:\Users\user> connect-AzAccount -DeviceCode
WARNING: You may need to login again after updating "EnableLoginByWam".
Please select the account you want to login with.
[Login to Azure] To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code I8Z4LTTZ9 to authenticate.
PowerShell上に表示されたURLにアクセスします。
そうするとcodeを求められるので、こちらも表示されたコードを入力します。
ログインアカウントを聞かれます。私は既にサインイン済みのアカウントが表示されたので、そちらを選択。
これでAzureにログイン完了です。
以上。