PowerShell offers a set of modules specifically tailored for Azure Stack Hub, providing an interface for automating and scripting tasks. However, before getting started, we need to ensure the installation of the Azure Stack compatible AzureRM modules. Always ensure the latest versions are installed to maintain updated functionality.
Installing Azure Stack Compatible AzureRM Modules
First, make sure PowerShell 5.1 or later is installed. If not, you might want to update it before proceeding.
To install AzureRM, the high-level steps are as follows:
- Check the installed versions:
Get-Module -Name AzureRm -ListAvailable
- If there are modules of AzureRM already installed, you’ll need to uninstall them:
Uninstall-Module AzureRm -AllVersions
- Open your PowerShell session with “Run as Administrator” and install the AzureRM module:
# Install and import the API Version Profile required by Azure Stack Hub
Install-Module -Name AzureRM -RequiredVersion 2.4.0
Installing PowerShell Az Module for Azure Stack Hub
The Az module is the successor of the AzureRm module, and it contains all the cmdlets of the AzureRm module. Starting from December 2018, Az PowerShell module received constant updates and bug fixes while AzureRm became obsolete.
To install the PowerShell Az module on your Azure Stack Hub, follow the steps below:
- Uninstall the AzureRM module because the Az and AzureRm modules cannot be imported into the same PowerShell session or used in the same script:
# Run in the Admin mode
Uninstall-Module -Name AzureRM -AllVersions
Uninstall-AzureRM -AllVersions
- Install the PowerShell Az module:
# Install Azure Az Powershell module
Install-Module -Name PowerShellGet -Force -AllowClobber
Install-Module -Name Az -AllowClobber -Scope AllUsers
- Restart your PowerShell session to load the new module:
# Close and Open admin powershell console
exit
- Validate the installation:
Get-InstalledModule -Name Az
In conclusion, the PowerShell modules are great solutions for you to automate, script and manage resources with Azure Stack Hub. As a candidate for the AZ-600 exam, mastering the installation of these modules is crucial to showcase your proficiency in configuring and operating a hybrid cloud with Microsoft Azure Stack Hub.
Practice Test
True or False: PowerShell Core can be used with Azure Stack Hub.
- True
- False
Answer: True.
Explanation: Azure Stack Hub supports PowerShell Core, which includes functionalities required to manage and administer Azure Stack Hub.
What is the purpose of installing PowerShell Az module for Azure Stack Hub?
- a) To manage Azure Stack Hub storage
- b) To delete Azure Stack Hub
- c) To manage and administer Azure Stack Hub
- d) To speed up Azure Stack Hub’s performance
Answer: c) To manage and administer Azure Stack Hub.
Explanation: The Az module provides cmdlets that you use to manage and administer Azure Stack Hub.
Multiple select: Which modules are used for different tasks in Azure Stack Hub?
- a) Az.Accounts
- b) Az.Business
- c) Az.Resources
- d) Az.Websites
Answer: a) Az.Accounts, c) Az.Resources and d) Az.Websites.
Explanation: The Az.Accounts module is used for authentication, Az.Resources to manage resources, and Az.Websites to manage web apps. Az.Business module is not a part of Azure Stack Hub.
In order to install the PowerShell Az module, you should run which one of the following commands?
- a) Install-Module -Name Az -AllowClobber -Scope AllUsers
- b) Install-Module -Name Az -AllowClobber -Scope CurrentUser
- c) Delete-Module -Name Az -AllowClobber -Scope CurrentUser
- d) Update-Module -Name Az -AllowClobber -Scope CurrentUser
Answer: b) Install-Module -Name Az -AllowClobber -Scope CurrentUser.
Explanation: This command installs the Az module for the current user.
The Get-Module -ListAvailable Az* command is used to do what?
- a) List all available Azure modules
- b) Delete all available Azure modules
- c) Update all available Azure modules
- d) Install all available Azure modules
Answer: a) List all available Azure modules.
Explanation: This command lists all the Azure modules available in the PowerShell instance.
True or False: All Az modules and versions are compatible with Azure Stack Hub.
- True
- False
Answer: False.
Explanation: Not all Az modules and versions are compatible with Azure Stack Hub. You should consult the documentation to verify compatibility.
Which command is used to connect to Azure Stack Hub?
- a) Connect-AzAccount
- b) Connect-AzureAccount
- c) Connect-AzStackHub
- d) Connect-AzureStackHub
Answer: a) Connect-AzAccount.
Explanation: The Connect-AzAccount command is used to connect to Azure Stack Hub.
Multiple select: Some of the PowerShell modules for Azure Stack Hub are:
- a) Az.Accounts
- b) Az.Storage
- c) Az.Network
- d) Az.VM
Answer: a) Az.Accounts, b) Az.Storage, c) Az.Network, and d) Az.VM.
Explanation: These are some of the PowerShell modules used to perform various operations in Azure Stack Hub.
Which command is used to list all the Azure Stack-compatible module versions?
- a) Get-AzModule
- b) Get-AzSModuleVersion
- c) Get-AzModuleVersion
- d) Get-ModuleVersion
Answer: b) Get-AzSModuleVersion.
Explanation: This cmdlet is used to list all the Azure Stack-compatible module versions.
True or False: You do not need to update the PowerShell Az modules once installed.
- True
- False
Answer: False.
Explanation: For optimal performance and latest features, it is recommended to regularly update the PowerShell Az modules.
Interview Questions
What is the first step in installing PowerShell modules for Azure Stack Hub?
The first step is to install the required version of PowerShell and NuGet.
Which version of PowerShell should be used to install Azure Stack modules?
PowerShell 5.1 or later should be used to install Azure Stack modules.
How can you check your installed PowerShell version?
You can check your installed PowerShell version by using the command $PSVersionTable.PSVersion in PowerShell.
What is the purpose of NuGet provider in the process of Azure Stack module installation?
NuGet is used as a package provider for PowerShell modules installation. It downloads and installs the necessary dependencies for Azure Stack Hub.
For installing PowerShell modules for Azure Stack, which version of NuGet is required?
The minimum required version of NuGet for installing PowerShell modules for Azure Stack is 2.8.5.201.
How do you install NuGet provider?
You can install NuGet provider by executing the command “Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force” in the PowerShell.
What does the AzureRM module do in Azure Stack Hub?
The AzureRM module is used for task automation and configuration management in Azure Stack Hub.
How can you install the AzureRM module?
You can install the AzureRM module by executing “Install-Module -Name AzureRM -RequiredVersion 2.5.0” in PowerShell.
What is Azure Stack Hub PowerShell module?
Azure Stack Hub PowerShell module provides cmdlets for managing Azure Stack Hub resources, ensuring that the same version of PowerShell is being used on both local and cloud resources.
How do you install the Azure Stack Hub PowerShell module?
To install Azure Stack Hub PowerShell module, you execute the command “Install-Module -Name AzureStack -RequiredVersion 1.8.0” in PowerShell.
Why do you need to run PowerShell as an administrator when installing Azure Stack modules?
Running PowerShell as an administrator ensures the correct permissions to install the necessary modules and make changes to your system.
What is the command to update the PowerShell module in Azure Stack Hub?
The command to update the PowerShell module in Azure Stack Hub is “Update-Module”.
Can an earlier version of Azure Stack Hub PowerShell module coexist with a newer version?
No, when you install a newer version of the Azure Stack Hub PowerShell module, the earlier version gets replaced.
What happens if the PowerShellGet or NuGet versions are not up-to-date while installing Azure Stack module?
If either PowerShellGet or NuGet versions are not up-to-date, the installation of Azure Stack module fails with an error message.
What is the command to uninstall a PowerShell module?
The command to uninstall a PowerShell module is “Uninstall-Module -Name”.