Paul
Paul

Reputation: 1620

Can you pipe the output of one PowerShell task to another in release management?

Here's a sample scenario:

  1. An "Azure PowerShell" task to deploy an ARM template. All the ARM template does is create an App Service Plan, a Web App and a storage account.
  2. An "Azure Web App Deployment" task to deploy a web app.
  3. An "Azure PowerShell task to update the configuration of the web app to contain reference to the storage keys generated from the ARM template.

How do I provide the third task with the output of the first task? Is there another way to approach this?

Upvotes: 3

Views: 749

Answers (3)

bmoore-msft
bmoore-msft

Reputation: 8737

Paul another way you could accomplish this is by doing all 3 in your first task (Azure PowerShell) - you could also combine 1 and 3 and leave 2 separate, either should work for you using the stock "tasks" in VSTS.

So the first step in your workflow about can create the web app (et al), update the configuration and deploy the webapp. If deploying the webapp in the template isn't desirable, you can combine step 1 & 3 in your workflow and do site deployment separately. Take a look at these examples, combined they do what you want (I couldn't find a single example quickly):

https://github.com/davidebbo/AzureWebsitesSamples/blob/master/ARMTemplates/WebAppDeployment.json (this shows how to do app configuration)

You can reference your storage keys in the same deployment that creates the storage account see: https://github.com/rjmax/ArmExamples/blob/fa4359bd393692bbb07b4460636c5b754191e42d/listKeysSample.json)

https://github.com/davidebbo/AzureWebsitesSamples/blob/master/ARMTemplates/WordpressTemplateWebDeployDependency.json (this shows how to do webdeploy in the template)

Upvotes: 1

Vijay Machiraju
Vijay Machiraju

Reputation: 176

You can use task logging commands in VSTS to "output" variables from one task and read them in the other. The first Azure PS task in your example could log an output variable that can later be read in the last one. See https://github.com/Microsoft/vso-agent-tasks/blob/master/docs/authoring/commands.md for format of these logging commands.

Upvotes: 3

Michael B
Michael B

Reputation: 12228

It is possible to 'chain' ARM templates together via the 'output' section to share state from one template to another.

So you can specify an output from one template, and either pick that output up via the Powershell script that calls it, or you can chain the templates together so they all run from a single New-AzureRmResourceGroupDeployment call. With the template for the Web app configuration task directly picking up the output of the deployment template.

There is some good documentation here - Sharing state in Azure Resource Manager templates

Upvotes: 0

Related Questions