You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: Move and improve Devops documentation (#447)
* move docs
* unique name
* fix links
* relocate docs
* chapters
* add `ArmOutputs: $(ArmOutputs) # only needs to be set for Linux agents`
* Update docs/preview/03-Features/powershell/azure-devops.md
Co-authored-by: Frederik Gheysels <frederik.gheysels@telenet.be>
---------
Co-authored-by: Frederik Gheysels <frederik.gheysels@telenet.be>
In ARM and Bicep templates it is possible to specify [output parameters](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/outputs), this enables you to return values from the deployed resources.
126
+
127
+
To enable maximum re-use of these output parameters within your environment we developed [this script](#setting-arm-outputs-to-azure-devops-variable-group) which is available in the `Arcus.Scripting.DevOps` PowerShell module. It allows you to store those output parameters in an Azure DevOps variable group. This helps you in making sure certain parameters are available throughout your Azure DevOps environment.
128
+
129
+
For example, think of a use-case where your vital infrastructure components are deployed in a separate Azure DevOps pipeline and need to be referenced from other components. Storing the necessary information such as identifiers, locations or names of these components in an Azure DevOps variable group allows you to easily use these values from other components.
130
+
131
+
#### Example
132
+
##### Specify Output Parameters
133
+
So how does this work in practice? Let's take an example where we will deploy a very basic Application Insights instance and specify the `Id` and `ConnectionString` of the Application Insights instance as output parameters.
Now that we have walked through both steps, let's take a look on how to combine all this into an Azure DevOps pipeline.
167
+
For this we use YAML and define two tasks, the first will deploy our Application Insights instance and the second will update our Azure DevOps variable group.
There are a few things worth noting. First of all we define `deploymentOutputs: ArmOutputs` during the `AzureResourceGroupDeployment@3` task. This means that the output parameters we specified in our Bicep template will be placed in a variable called `ArmOutputs`, this is then referenced during the execution of our script with `-ArmOutputsEnvironmentVariableName 'ArmOutputs'`.
196
+
197
+
Secondly we use `-UpdateVariablesForCurrentJob` as a parameter when calling the script. This means that the output parameters from the Bicep file are also available as pipeline variables in the current running job. While not necessary in our example here, if you need to deploy another Bicep template that needs output parameters from an earlier deployed Bicep template this is the way to do it.
198
+
199
+
Finally we use `system_accesstoken: $(System.AccessToken)` in the `Powershell@2` task, this is necessary because we need to use the security token used by the running build.
200
+
> Please note that the `ArmOutputs` variable is not available 'as is' when executing the Powershell task on a Linux agent. When using a Linux agent, you have to explicitly add that variable in the `env:` section of the Powershell task.
201
+
#### Closing Up
202
+
Using this setup we are able to deploy a Bicep template and update an Azure DevOps variable group with the specified output parameters!
203
+
204
+
> ⚠ Before running your pipeline, make sure the variable group already exists in Azure DevOps and the permissions below are set:
0 commit comments