5

I am trying to run the Get-AzureRmEventHubNamespaceKey cmdlet in an Azure Powershell step within Octopus.

I am getting the following error:

Get-AzureRmEventHubNamespaceKey : The Azure PowerShell session has not been properly 
                                  initialized.  Please import the module and try again

The module is installed in the following directory on the Octopus server:

C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureRM.EventHub

I have tried importing the module first as part of the same step:

Import-Module –Name "C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureRM.EventHub" -Verbose

And I can see in the output that it has been imported:

VERBOSE: Importing cmdlet 'Get-AzureRmEventHubNamespaceKey'.

But it is immediately followed by the above error. If I RDP to the octopus server and run directly from there it runs fine.

Any ideas on what might be causing this?

Declan McNulty
  • 3,194
  • 6
  • 35
  • 54
  • i wonder if you have to login first? try updating the module also? – 4c74356b41 Jun 14 '17 at 15:03
  • This could be because of path mismatch when remote. Can you try uninstall all previous AzurePowershell Modules and try getting the latest. Note: Get-AzureRmEventHubNamespaceKey is retired from 5.0.0 and replaced with Get-AzureRmEventHubKey – Pradebban Raja Jan 11 '18 at 19:31

1 Answers1

0

To use any Azure related commands from your machine, you need to log in first.

Note that there are several Azure modules, and each has a different login cmdlet, but the link above is specific to the module you're using.

Jonathon Anderson
  • 1,162
  • 1
  • 8
  • 24