Prepare the online (internet-connected) computer
All procedures in this section should be completed on the online (internet-connected) computer.
Upgrade PowerShell
-
Open a PowerShell console with administrator privileges.
-
Check the version of PowerShell. Version 7 or higher is recommended. If so, go to the next section. Otherwise, continue to the next step.
> $PSVersionTable.PSVersion Major Minor Build Revision ----- ----- ----- -------- 5 1 22000 3260 -
Search for the latest version of PowerShell
> winget search --id Microsoft.PowerShell The `msstore` source requires that you view the following agreements before using. Terms of Transaction: https://aka.ms/microsoft-store-terms-of-transaction The source requires the current machine's 2-letter geographic region to be sent to the backend service to function properly (ex. "US"). Do you agree to all the source agreements terms? [Y] Yes [N] No: Y Name Id Version Source --------------------------------------------------------------- PowerShell Microsoft.PowerShell 7.5.4.0 winget PowerShell Preview Microsoft.PowerShell.Preview 7.6.0.5 winget -
Upgrade the PowerShell version.
> winget install --id Microsoft.PowerShell --source winget Found PowerShell [Microsoft.PowerShell] Version 7.5.4.0 This application is licensed to you by its owner. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages. Downloading https://github.com/PowerShell/PowerShell/releases/download/v7.5.4/PowerShell-7.5.4-win-x64.msi ██████████████████████████████ 107 MB / 107 MB Successfully verified installer hash Starting package install... Successfully installed -
The default execution policy only allows digitally signed scripts to protect you against hacks from downloaded scripts. All Microsoft scripts are digitally signed. However, your own local scripts may not be digitally signed. These would not be allowed to run under the default execution policy. The following command changes the execution policy to allow your own unsigned scripts to run. When prompted, enter A for yes to all.
> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser Execution Policy Change The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks described in the about_Execution_Policies help topic at https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A -
Verify the execution policy change made above.
> Get-ExecutionPolicy RemoteSigned
Install the Azure PowerShell module
-
Open a PowerShell console with administrator privileges.
-
Enter the following command. The command prompt will return when the installation has completed.
> Install-Module -Name Az -Repository PSGallery -Force -
The
Azmodule needs to be imported before it can be used. The command prompt will return when the module has completed loading.> Import-Module Az WARNING: The names of some imported commands from the module 'Az.Cdn.private' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb. ... -
Verify the
Azmodule is properly loaded and ready for use.> Get-Module -Name Az* ModuleType Version Name ExportedCommands ---------- ------- ---- ---------------- Script 5.3.1 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear...
Install the Azure CLI
-
Open a PowerShell console with administrator privileges.
-
Enter the following command.
> winget install --exact --id Microsoft.AzureCLI Found Microsoft Azure CLI [Microsoft.AzureCLI] Version 2.80.0 This application is licensed to you by its owner. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages. Downloading https://azcliprod.blob.core.windows.net/msi/azure-cli-2.80.0-x64.msi ██████████████████████████████ 65.6 MB / 65.6 MB Successfully verified installer hash Starting package install... Successfully installed Notes: Winget installs the 64-bit CLI on 64-bit OS by default now. If you have used the 32-bit CLI before, please follow this guide to migrate to 64-bit version: https://learn.microsoft.com/cli/azure/install-azure-cli-windows#migrate-to-64-bit-azure-cli -
Close the PowerShell console.
-
Open a new PowerShell console with administrator privileges and test the installation by running the following command.
> az Welcome to Azure CLI! --------------------- Use `az -h` to see available commands or go to https://aka.ms/cli. ...
Sign into Azure with Az PowerShell
-
Open a PowerShell console with administrator privileges.
-
Sign into Azure. If multiple subscriptions are listed, enter the one to be used for BYOK.
> az login --tenant <tenant-id>For example:
> az login --tenant ... Select the account you want to log in with. For more information on login with Azure CLI, see https://go.microsoft.com/fwlink/?linkid=2271136 Retrieving subscriptions for the selection... [Tenant and subscription selection] No Subscription name Subscription ID Tenant ----- -------------------- ------------------------------------ ------------------------------------ [1] * Azure subscription 1 ... ... The default is marked with an *; the default tenant is '...' and subscription is 'Azure subscription 1' (...). Select a subscription and tenant (Type a number or Enter for no changes): Tenant: ... Subscription: Azure subscription 1 (...) [Announcements] With the new Azure CLI login experience, you can select the subscription you want to use more easily. Learn more about it and its configuration at https://go.microsoft.com/fwlink/?linkid=2271236 If you encounter any problem, please open an issue at https://aka.ms/azclibug [Warning] The login output has been updated. Please be aware that it no longer displays the full list of available subscriptions by default.