Azure PowerShell Script or Standard Powershell Script

Hi,

I have a script which was running fine when running as an Azure PowerShell script however I have had to convert this to run as a normal PowerShell script.

Since doing this it is saying I am now missing a module. Does anyone know what modules are loaded when running an Azure PowerShell step template so I can manually load them?

Thanks

Hi Michael,

Thanks for getting in touch! Running this scrip manually can be a pain, but overall not too much of a problem. There are a couple of things you will need to explicitly define, which Octopus would otherwise do for you in the step template.

You should be able to manage it by manually installing the Azure PowerShell module on your target (install-module Azure). Next you will need to specify a few project variables which will be used for your Azure connection. You will need the following:

ApplicationID: To get the Application ID, login to the Azure portal, select Azure Active Directory > App Registrations > Select the service principal and copy the Application ID
TenantID: The TenantID can be found by running get-AzureRmSubscription while logged into Azure PowerShell.
ApplicationApiKey: This is the API key for your service principal account.

Once you have the above as project variables, you can create a script step with the following:

$secpasswd = ConvertTo-SecureString $ApplicationApiKey -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ($ApplicationId, $secpasswd)

Login-AzureRmAccount -Credential $mycreds -ServicePrincipal -TenantId $tenantid

This should be enough to get your custom template running. :slight_smile:

Please let me know if you have any questions, or if this gives you and problems.

Best regards,
Daniel

Installing the module didnt seem to work. Closing this as we have worked around our particular issue