AzureRm

I have installed azurerm modules on octopus server (through ise x64 and ise x86) but can not run any rm commandlets as part of octopus steps… i.e running
LogIn
{
#Login-AzureRMAccount #(Interactive login)

# use the saved password 
$password = ConvertTo-SecureString  "***" -AsPlainText -Force
# currently (August, the 13nd, 2014) only organizational accounts are supported (also with custom domain). 
# Microsoft Accounts (Live ID) are not supported 
$username = "***" 
$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$password 
#Add-AzureAccount -credential $mycred
Login-AzureRmAccount -Credential $mycred

}

LogIn

Fails with Login-AzureRmAccount : The term ‘Login-AzureRmAccount’ is not recognized as the name of a cmdlet, function, script …

While running it on ise on octopus server doesnt fail

Hi,

Thanks for getting in touch! Based on what you described, we have a couple of ideas of what may be causing the modules to not work as expected. To help narrow down the cause, could you answer a few additional questions?

Are you running the script on a remote Tentacle? That would require installing the AzureRm module on that remote Tentacle.

Does this script successfully run via the Script Console (Tasks -> Script Console)?

Could you include a screenshot of this deployment step (ProjectName -> Process -> StepName)?

Could you also attach a raw deployment log (You can get this by selecting the Task Log tab after a deployment, select ‘Raw’, and ‘Download’)?

I look forward to hearing back!

Kenny

The script runs on octopus server. (Not on tentacle)
I am not running this script against a deployment target, so I can not run it on tasks>script console
The script is for provisioning an azureRM virtual machine along with associated resources.
AzurRM module is installed on octopus server (done through bot x86 and 64 ise)

Screenshot below, log attached
[cid:image001.png@01D2716C.CAA5DD00]

Log.txt (3 KB)

Hi dudes… any news on this… I got my governor boiling eggs on my neck

Hi,

Thanks for following up! And I’m very sorry for the delay in getting back to you! It looks like you’re using a standard script step instead of the Azure specific script step. If you use the “Run an Azure PowerShell Script” step type, as described here: http://docs.octopusdeploy.com/display/OD/Azure+PowerShell+scripts your login method should then work. Octopus loads Azure modules which are bundled within, but they are only applied on the Azure specific steps.

I hope that helps! Please don’t hesitate to get in touch if you have any further questions.

Kenny

Is there any way that we can load the Azure modules on a standard script step.

I just found that you can load them like this:
Import-Module "C:\Octopus\Calamari\Azure\3.6.30\PowerShell\ResourceManager\AzureResourceManager\AzureRM.Profile\AzureRM.Profile.psd1"
Import-Module “C:\Octopus\Calamari\Azure\3.6.30\PowerShell\Storage\Azure.Storage\Azure.Storage.psd1”

Hi Patrice,

Thanks for reaching out! While you can hardcode the paths to import the modules in the script step as you’ve done, we recommend instead using the Run an Azure PowerShell Script step, as Calamari will import the modules automatically. Is there a specific reason you want to use the standard script step instead?

Kind regards,

Kenny

On of the reason we cannot run it is an azure PowerShell script step is that we needed to have a Apply XML transform action in the same step.

Resolved thank you