3

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?

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
Paul
  • 1,590
  • 5
  • 20
  • 41
  • To answer your specific question, check the documentation for each commandlet - it will describe what it generates, and also what parameters it takes from the pipeline. In general, if the object that is being created from each of the commands you reference contains the information you need for the next task (or offers a way to gather that info) then of course there's a way to glue them together. Have you tried it? – Chris N Jan 21 '16 at 20:53
  • From a pure PowerShell/commandlet perspective, this is totally possible. I can pipe the output of one commandlet to another. My challenge is in making this work within Release Management where each individual commandlet is "wrapped" in a Release Management task. https://www.visualstudio.com/en-us/features/release-management-vs.aspx – Paul Jan 21 '16 at 20:57

3 Answers3

3

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.

  • Thanks for your response. Technically, this answered my question, but I think @bmoore-msft's response is probably the way I should have approached the problem in the first place. – Paul Jan 23 '16 at 02:16
1

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)

bmoore-msft
  • 8,376
  • 20
  • 22
  • This is exactly the path we started going down yesterday. What was great about your post was the link regarding referencing storage keys (using listKeys() in the same ARM deployment as it was a bit painful to discover how to reference the storage key. We needed the first key returned from the listKeys method. I thought this method returned a collection of keys, but instead it returns an object w/a property called key1. I found that here: https://github.com/Azure/azure-quickstart-templates/blob/master/201-list-storage-keys-windows-vm/azuredeploy.json – Paul Jan 23 '16 at 02:12
0

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

Michael B
  • 11,887
  • 6
  • 38
  • 74
  • Thanks for your response. However, I wasn't looking to chain ARM templates... The issue was more concerned w/piping output from one PowerShell RM task to another. – Paul Jan 23 '16 at 02:14
  • 1
    @Paul I suspected it wasn't the answer you were looking for (and largely expected a downvote for it) but it could be the answer to someone searching this question in future. So figured I'd leave it behind anyway. I'm glad you got sorted though. – Michael B Jan 23 '16 at 07:18