actions / runner-images

GitHub Actions runner images
MIT License
10.13k stars 3.05k forks source link

Az Modules missing from ubuntu #5354

Closed BenH-Puregym closed 2 years ago

BenH-Puregym commented 2 years ago

Description

I've updated to the latest commits and now it doesn't add Az modules.

running this command gets the below error: Get-InstalledModule -Name Az Get-Package: No match was found for the specified search criteria and module names 'Az'.

and running this only gets the new microsoft.graph module added the other week: get-module -listavailable

Script 1.9.3 Microsoft.Graph.CloudCommunications Core,Desk Script 1.9.3 Microsoft.Graph.Compliance Core,Desk Script 1.9.3 Microsoft.Graph.CrossDeviceExperie… Core,Desk Script 1.9.3 Microsoft.Graph.DeviceManagement Core,Desk Script 1.9.3 Microsoft.Graph.DeviceManagement.A… Core,Desk Script 1.9.3 Microsoft.Graph.DeviceManagement.A… Core,Desk Script 1.9.3 Microsoft.Graph.DeviceManagement.E… Core,Desk Script 1.9.3 Microsoft.Graph.DeviceManagement.F… Core,Desk Script 1.9.3 Microsoft.Graph.Devices.CloudPrint Core,Desk Script 1.9.3 Microsoft.Graph.Devices.CorporateM… Core,Desk Script 1.9.3 Microsoft.Graph.Devices.ServiceAnn… Core,Desk Script 1.9.3 Microsoft.Graph.DirectoryObjects Core,Desk Script 1.9.3 Microsoft.Graph.Education Core,Desk Script 1.9.3 Microsoft.Graph.Files Core,Desk Script 1.9.3 Microsoft.Graph.Financials Core,Desk Script 1.9.3 Microsoft.Graph.Groups Core,Desk Script 1.9.3 Microsoft.Graph.Identity.Directory… Core,Desk Script 1.9.3 Microsoft.Graph.Identity.Governance Core,Desk Script 1.9.3 Microsoft.Graph.Identity.SignIns Core,Desk Script 1.9.3 Microsoft.Graph.Mail Core,Desk Script 1.9.3 Microsoft.Graph.Notes Core,Desk Script 1.9.3 Microsoft.Graph.People Core,Desk Script 1.9.3 Microsoft.Graph.PersonalContacts Core,Desk Script 1.9.3 Microsoft.Graph.Planner Core,Desk Script 1.9.3 Microsoft.Graph.Reports Core,Desk Script 1.9.3 Microsoft.Graph.SchemaExtensions Core,Desk Script 1.9.3 Microsoft.Graph.Search Core,Desk Script 1.9.3 Microsoft.Graph.Security Core,Desk Script 1.9.3 Microsoft.Graph.Sites Core,Desk Script 1.9.3 Microsoft.Graph.Teams Core,Desk Script 1.9.3 Microsoft.Graph.Users Core,Desk Script 1.9.3 Microsoft.Graph.Users.Actions Core,Desk Script 1.9.3 Microsoft.Graph.Users.Functions Core,Desk Script 1.9.3 Microsoft.Graph.WindowsUpdates Core,Desk Script 5.3.1 Pester Desk

Directory: /opt/microsoft/powershell/7/Modules

ModuleType Version PreRelease Name PSEdition


Manifest 1.2.5 Microsoft.PowerShell.Archive Desk
Manifest 7.0.0.0 Microsoft.PowerShell.Host Core
Manifest 7.0.0.0 Microsoft.PowerShell.Management Core
Manifest 7.0.0.0 Microsoft.PowerShell.Security Core
Manifest 7.0.0.0 Microsoft.PowerShell.Utility Core
Script 1.4.7 PackageManagement Desk
Script 2.2.5 PowerShellGet Desk
Script 2.1.0 PSReadLine Desk
Binary 2.0.3 ThreadJob Desk

Virtual environments affected

Image version and build link

not sure

Is it regression?

No response

Expected behavior

No response

Actual behavior

No response

Repro steps

pull in the repo and run it in devops pipeline, then applied to scale set.

josefschabasser commented 2 years ago

I just wanted to create an issue, happens here as well.

al-cheb commented 2 years ago

Hello, By default we install az module at the /usr/share path.

- name: Get Az Module
  shell: pwsh
  run: |
        $env:PSModulePath += ":/usr/share/az_7.1.0"
        Get-Module -List

image

josefschabasser commented 2 years ago

Hello, By default we install az module at the /usr/share path.

If they're installed in a different location, why not add this location to the default configuration to make them usable out of the box? Is this documented somewhere?

BenH-Puregym commented 2 years ago

is there any reason why you haven't added $env:PSModulePath += ":/usr/share/az_7.1.0" to the image?

al-cheb commented 2 years ago

Hello, By default we install az module at the /usr/share path.

If they're installed in a different location, why not add this location to the default configuration to make them usable out of the box? Is this documented somewhere?

The current logic you can find here - https://github.com/actions/virtual-environments/pull/2828

al-cheb commented 2 years ago

is there any reason why you haven't added $env:PSModulePath += ":/usr/share/az_7.1.0" to the image?

We don't want to break anyone. The best practice is to use tasks to import Az module: (GitHub Actions task) - azure/powershell (Azure DevOps) - AzurePowerShell

E.g.:

- name: Run Azure PowerShell script
  uses: azure/powershell@v1
  with:
     inlineScript: |
            Get-Module
     azPSVersion: "latest

image

Or use $env:PSModulePath += ":/usr/share/" statement in your pipeline.

BenH-Puregym commented 2 years ago

how would you suggest we add this path to the image?

Although what you've suggested lists the Az modules it only works for that task and so doesn't resolve anything.

al-cheb commented 2 years ago

how would you suggest we add this path to the image?

Although what you've suggested lists the Az modules it only works for that task and so doesn't resolve anything.

@BenH-Puregym , Do you mean your own self-generated image?

al-cheb commented 2 years ago

Feel free to open the thread if you have any questions.

josefschabasser commented 2 years ago

I think this was closed due to the fact that there are 2 possible tasks:

To use the Azure-modules without logging in (e.g. just use a storage account key), place $env:PSModulePath += ":/usr/share/az_7.1.0" before importing the modules. This requires A LOT of attention as it will break on every version change - better use AzurePowerShell@5 with a proper service connection (or write some code to build the path with the correct version number, but I would highly disregard that).