Skip to content

Commit

Permalink
Added install azps optimized article (#3427)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikefrobbins authored Dec 5, 2024
1 parent 65c1dac commit 43dfb27
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 0 deletions.
116 changes: 116 additions & 0 deletions docs-conceptual/azps-13.0.0/install-azps-optimized.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
---
description: Learn how to optimize the installation of Azure PowerShell using PSResourceGet and install only the modules you need.
ms.custom: devx-track-azurepowershell
ms.devlang: powershell
ms.service: azure-powershell
ms.topic: conceptual
title: Optimize the installation of Azure PowerShell
---

# Optimize the installation of Azure PowerShell

This article explores how to optimize the Azure PowerShell installation process by selectively
installing only the modules you need using the **Microsoft.PowerShell.PSResourceGet**
(PSResourceGet) PowerShell module, an improved package management solution introduced with
PowerShell version 7.4.

## Prerequisites

Determine if the **PSResourceGet** PowerShell module is installed and install it if necessary. The
**PSResourceGet** module provides improved capabilities for installing PowerShell resources,
including Azure PowerShell modules. **PSResourceGet** is preinstalled with PowerShell version 7.4 or
higher and is also supported in Windows PowerShell 5.1.

1. Determine if the **PSResourceGet** PowerShell module is installed.

```powershell
Get-Module -Name Microsoft.PowerShell.PSResourceGet -ListAvailable
```

1. Install the **PSResourceGet** PowerShell module.

```powershell
Install-Module -Name Microsoft.PowerShell.PSResourceGet -Repository PSGallery
```

## The Az PowerShell module

Azure PowerShell is the product name for the collection of official Microsoft PowerShell modules for
managing Azure resources. The **Az** PowerShell module is the current iteration of Azure PowerShell.

The **Az** PowerShell module is a wrapper module for Azure service-related PowerShell modules,
usually one module per Azure service, such as **Az.Compute**, **Az.Network**, and **Az.Storage**.
When you install the **Az** PowerShell module, you install all the generally available (GA) Azure
PowerShell service-specific modules.

Each submodule of the **Az** PowerShell module depends on the **Az.Accounts** module, which provides
the core authentication and account management capabilities for Azure PowerShell. When you use
`Install-Module` (part of **PowerShellGet**) to install the **Az** PowerShell module, the
**Az.Accounts** module is downloaded and installed for each submodule. This redundant download
process increases the installation time.

**PSResourceGet** installs **Az.Accounts** only once, regardless of the number of submodules you
install. This results in a faster, more efficient installation process.

```powershell
Install-PSResource -Name Az
```

## Install individual service-specific modules

Installing the entire **Az** PowerShell module with all the service-specific modules bundled
together is convenient, but time-consuming and inefficient if you only use a subset of its commands.
Installing the entire **Az** PowerShell module results in:

- **Longer installation times**.
- **Increased storage requirements**.
- **Unnecessary updates** for modules you don't use.

You can streamline the process by installing only the service-specific modules you need. The
combination of using **PSResourceGet** and installing only the modules you need dramatically
reduces installation overhead.

The following example uses the `Install-PSResource` cmdlet to install the **Az.Compute**,
**Az.Network**, **Az.Resources**, and **Az.Storage** PowerShell modules.

```powershell
Install-PSResource -Name Az.Compute, Az.Network, Az.Resources, Az.Storage
```

The **Az.Accounts** module is also installed automatically, but only once.

## Install all GA and preview modules

If you need all the general availability (GA) and preview versions of **Az** PowerShell modules,
install the **AzPreview** module. The **AzPreview** PowerShell module mirrors the structure of the
**Az** module but includes all GA and preview modules. For consistency, its version number is the
same as the **Az** module.

The following example installs the **AzPreview** module using **PSResourceGet**.

```powershell
Install-PSResource -Name AzPreview
```

## Benefits of optimizing the installation process

By adopting a more selective and efficient installation process, you:

- **Reduce resource consumption**: Install only what you need, saving disk space.
- **Improve performance**: Avoid redundant downloads and streamline the setup process.
- **Stay agile**: Update and maintain only the modules you actively use.

## See also

- [Install Microsoft.PowerShell.PSResourceGet][install-psresourceget]
- [Install-PSResource][install-psresource]

## Next Steps

To learn more about managing your Azure resources with the **Az** PowerShell module, see
[Get Started with Azure PowerShell][get-started-azps].

<!-- link references -->
[install-psresourceget]: /powershell/gallery/powershellget/install-powershellget#install-microsoftpowershellpsresourceget
[install-psresource]: /powershell/module/microsoft.powershell.psresourceget/install-psresource
[get-started-azps]: get-started-azureps.md
2 changes: 2 additions & 0 deletions docs-conceptual/azps-13.0.0/install-azure-powershell.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ release, see the [release notes](release-notes-azureps.md).
- [Install on Windows](install-azps-windows.md)
- [Install on Linux](install-azps-linux.md)
- [Install on macOS](install-azps-macos.md)
- [Optimize the installation](install-azps-optimized.md)
- [Offline Installation](install-azps-offline.md)
- [Run in Azure Cloud Shell](https://shell.azure.com/)
- [Run in Docker container](azureps-in-docker.md)

Expand Down
2 changes: 2 additions & 0 deletions docs-conceptual/azps-13.0.0/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
href: install-azps-linux.md
- name: Install - macOS
href: install-azps-macos.md
- name: Install - Optimized
href: install-azps-optimized.md
- name: Offline Installation
href: install-azps-offline.md
- name: Run in Azure Cloud Shell
Expand Down

0 comments on commit 43dfb27

Please sign in to comment.