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

  2. 2 Posted by michael.chute on 04 Jan, 2018 04:55 PM

    michael.chute's Avatar

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

  3. michael.chute closed this discussion on 04 Jan, 2018 04:55 PM.

Comments are currently closed for this discussion. You can start a new one.

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