Question:
I am trying to run the Get-AzureRmEventHubNamespaceKey
cmdlet in an Azure Powershell step within Octopus.
I am getting the following error:
1 2 3 |
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?
Answer:
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.