Command from an Powershell module installed is not found in azure cloud shell

Ana Cortazar 21 Reputation points
2022-08-25T20:36:00.407+00:00

I'm working some powershell scripts to create resources in Azure portal, then I'm installed psazdevtestlabs module to use some commands there and it works fine locally but It is not working in Azure Cloud shell.

When I use command from that module, I got error "The term 'New-AzDevTestLabVM' 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 " :
234948-image.png

Then, I already compare PSModulePath Vs Path where is the psazdevtestlabs library and I found it is correct:

235022-psmodulepath.png

235023-cloudshellpath.png

So, I would like to know what am I doing incorrectly.

Thanks for helping me.

Azure Cloud Services
Azure Cloud Services
An Azure platform as a service offer that is used to deploy web and cloud applications.
636 questions
Azure DevTest Labs
Azure DevTest Labs
An Azure service that is used for provisioning development and test environments.
255 questions
{count} votes

Accepted answer
  1. Olga Os - MSFT 5,831 Reputation points Microsoft Employee
    2022-09-13T01:28:33.087+00:00

    Hello @Ana Cortazar ,

    I was getting the same failure as you and was able to resolve it by importing the module (step 2). After that no other issues or complications to build the Azure DevTest Lab and VM in the Azure CLI.

    My steps outlined below:

    Install-Module psazdevtestlabs -Scope CurrentUser -Force  
    Import-Module /home/system/.local/share/powershell/Modules/psazdevtestlabs/1.0.4/PSAzDevTestLabs.psm1  
    $subscriptionId = "####"  
    $rgName = 'test_group'  
    $labName = 'MyTestLab'  
      
    New-AzDevTestLab -SubscriptionId $subscriptionId -ResourceGroupName $rgName -Name $labName -VirtualNetworkName TestLabvNet  
    $publisher = (Get-AzVMImagePublisher -Location 'Central US').where({ $_.PublisherName -eq 'MicrosoftWindowsServer' })  
    $offer = (Get-AzVMImageOffer -Location 'Central US' -PublisherName $publisher.PublisherName).where({ $_.Offer -eq 'WindowsServer' })  
    $sku = (Get-AzVMImageSku -Location 'Central US' -PublisherName $publisher.PublisherName -Offer $offer.Offer).where({ $_.Skus -eq '2019-Datacenter-Core' })  
    $size = (Get-AzVMSize -Location 'Central US').where({ $_.Name -eq 'Standard_DS2_v2' })  
    
    $newVmParams = @{  
    Name              = 'MYTESTVM'  
    SubscriptionId    = $subscriptionId  
    ResourceGroupName = $rgName  
    LabName           = $labName  
    AdminUserName     = 'adam'  
    AdminPassword     = 's3cret p@ssword'  
    VMImageOffer      = $sku.Offer  
    VMImagePublisher  = $sku.PublisherName  
    VMImageSku        = $sku.Skus  
    VmSize            = $size.Name  
    }  
    New-AzDevTestLabVM @newVmParams        
    

    --------------------------

    Hope above answers your question and concern. Let me know if you need additional assistance. If the answer was helpful, please accept it and complete the quality survey so that others can find a solution.

    Sincerely,
    Olga


0 additional answers

Sort by: Most helpful