Azure PowerShell Script or Standard Powershell Script

michael.chute's Avatar

michael.chute

07 Dec, 2017 05:10 PM

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

  1. Support Staff 1 Posted by Daniel Fischer on 08 Dec, 2017 05:27 AM

    Daniel Fischer's Avatar

    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. :)

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

    Best regards,
    Daniel

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac