1
votes

In Azure I have created a new VM and using azure automation dsc I have uploaded my custom module. In my custom module I am using New-AzureStorageContext. But when VM is connected to DSC Node I get the below error.

The term 'New-AzureStorageContext' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

When I go to C:\Program Files\WindowsPowerShell\Modules folder in the new vm I do see my custom module imported but I do not see Azuer.Storage. I do see Azure.Storage as one of the default module in the Azure Automation Account. What am I missing?

Configuration Deploy
{ 
    Import-DscResource -ModuleName cWebPackageDeploy
    Import-DscResource -ModuleName Azure.Storage

    node "localhost"
    { 
         cWebPackageDeploy jswebpackage  
         { 
            Name = "website.zip"
            StorageAccount = "testdeploy"
            StorageKey = "xxxxxxxxxxxxxxxxxxxxxxx"
            Ensure = "Present"
            PackageVersion = "1.0"
            DeployPath = "C:\Temp\Testdeploy"
         }
    }
} 

Deploy 
1
Do you try install Azure PowerShell on your DSC node VM? You could download the latest msi installer from the link. I suggest you could install it firstly and try again. - Shui shengbao
I am using Azure Automation DSC. I had uploaded my custom resource in the module section in Azure Automation. In Modules section I do see Azure.Storage. Import-DscResource -ModuleName cWebPackageDeploy takes the uploaded package in the modules section and puts it in the azure vm. But when I try Import-Module -Name Azure.Storage or Import-DscResource It is not added it to the azure vm. If I need to install the whole Azure Powershell MSI. Should I add it to my dsc script as another resource? - kumar
Based on my experience, you could use dsc script to deploy Azure PowerShell module firstly. - Shui shengbao
I just came across another alternative to installing whole azure powershell. this seems to work for me powershellgallery.com/packages/PowerShellModule/0.3. This way i can install just the module I need. Would have preferred if the dsc script would just pickup the modules in Azure Automation automatically - kumar
Hi, kumar. Do you mean you import the module to Azure automation and solve your issue? - Shui shengbao

1 Answers

0
votes

Went to the below link and added this dsc resource to my azure automation. Then I updated PSModuleResource Azure.Storage to my dsc script.

https://www.powershellgallery.com/packages/PowerShellModule/0.3

Configuration Deploy
{ 
    Import-DscResource -ModuleName cWebPackageDeploy
    Import-Dscresource -ModuleName PowerShellModule  

    node "localhost"
    { 
         cWebPackageDeploy jswebpackage  
         { 
            Name = "website.zip"
            StorageAccount = "testdeploy"
            StorageKey = "xxxxxxxxxxxxxxxxxxxxxxx"
            Ensure = "Present"
            PackageVersion = "1.0"
            DeployPath = "C:\Temp\Testdeploy"
            DependsOn = "[PSModuleResource]Azure.Storage"
         }

          PSModuleResource Azure.Storage
         {
            Ensure = 'present'
            Module_Name = 'Azure.Storage'

         }
    }
} 

Deploy