Using Azure Powershell Script

Hi,

I’m trying to deploy an azure batch service using azure powershell script, want to replace values of a config file in the same step by using the package from octopus server packages feed. At this stage I have added all the variables needed and corresponding values to library. Looking forward for solution.

Thanks in advance.

Hi,

Thanks for reaching out! The features to replace values of config files are all included on the Deploy a package step. So instead of having everything in a single step, I’d recommend you to have 2 steps:

  1. Deploy the contents of the package to a folder in disk and replace the config file using this feature: https://octopus.com/docs/deploying-applications/configuration-files#Configurationfiles-VariablesInFilesReplacingvariablesoutsideappSettings,applicationSettingsandconnectionStrings

  2. Run your Azure Powershell Script and deploy your azure batch service using the files you deployed in the previous step.

Let me know if that’ll work for you.

Best regards,
Dalmiro

Hi Dalmiro,
I’ve created a step of “deploy a package” and the replacement of .config works fine. But, I’m actually wondering how to access the package in the powershell script? Can I get a resource (documentation) to find a way?

It would be a great help if I can find some sample script to deploy azure batch as well.

Thanks.

Hi,

If you want to access to contents of the package that were extracted during the “Deploy a package” step from your Powershell script step, you have 2 alternatives:

  1. Use the variable $OctopusParameters['Octopus.Action[Name of your deploy step].Output.Package.InstallationDirectoryPath'] in your powershell step. Make sure to replace the name of your deployment step on it. I recommend you to use our variables editor to get the right variable, just like I’m doing in the attached GIF

  2. In your “Deploy a package” step, use the Custom Installation Directory feature and send the package content to a fixed location in your machine. This way you’ll always know where the package contents will land, and you can reference that path in your powershell script.

As for a script to deploy Azure Batch, I’m afraid we don’t have such thing at hand.

Best regards,
Dalmiro

Hi Dalmiro,

I’ve used post deployment powershell script to solve the problem. Figured out the azure batch script as well.

Thanks.