Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
keesschollaart81 committed Apr 9, 2017
1 parent c5dbaa8 commit 2952e8a
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,6 @@ paket-files/
# JetBrains Rider
.idea/
*.sln.iml

# Custom
*.vsix
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,31 @@
# vsts-arm-outputs
VSTS Extension - Use ARM Deployment outputs
# vsts-arm-outputs - a VSTS Extension

Using this extenion in your VSTS environment enables you to use the values coming out of the ARM Deployment outputs.

This step will use the last successful deployment within the selected resource group. If this deployent has outputs, all of them are copied to VSTS variables by the ARM Output key.

```json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables":{},
"resources":{},
"outputs": {
"dbserver-fqdn": {
"type": "string",
"value": "[reference(concat('Microsoft.Sql/servers/',variables('dbserver-name'))).fullyQualifiedDomainName]"
},
"sample-variable": {
"type": "string",
"value": "[variables('sample-variable')]"
}
}
}
```

This outputs can then be used by default VSTS ways: ```$(sample-variable)```

Usually this task is ran directly after the 'Azure Resource Group Deployment' task.

//todo: screenshot of VSTS
89 changes: 89 additions & 0 deletions extension-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"manifestVersion": 1,
"id": "arm-outputs",
"name": "ARM Outputs",
"version": "1.0.0",
"publisher": "keesschollaart",
"public": false,
"helpMarkDown": "[More Information](https://github.com/keesschollaart81/vsts-arm-outputs)",
"targets": [
{
"id": "Microsoft.VisualStudio.Services"
}
],
"description": "Use ARM Deployment outputs",
"categories": [
"Build and release"
],
"tags": [
"azure",
"arm",
"template",
"build",
"release",
"output",
"variable",
"parameter",
"resource",
"group",
"deployment",
"resourcegroup"
],
"screenshots": [
{
"path": "images/screenshots-vsts-arm-outputs-1.png"
}
],
"content": {
"details": {
"path": "readme.md"
},
"license": {
"path": "LICENSE"
}
},
"links": {
"getstarted": {
"uri": "https://github.com/keesschollaart81/vsts-arm-outputs"
},
"support": {
"uri": "https://github.com/keesschollaart81/vsts-arm-outputs"
}
},
"branding": {
"color": "rgb(82,108,161)",
"theme": "light"
},
"icons": {
"default": "images/logo.png"
},
"files": [
{
"path": "src"
},
{
"path": "images/screenshots-vsts-arm-outputs-1.png",
"addressable": true
},
{
"path": "images/logo.png",
"addressable": true
}
],
"contributions": [
{
"id": "arm-outputs",
"type": "ms.vss-distributed-task.task",
"targets": [
"ms.vss-distributed-task.tasks"
],
"properties": {
"name": "arm-outputs"
}
}
],
"repository": {
"type": "git",
"uri": "https://github.com/keesschollaart81/vsts-arm-outputs"
}
}
Binary file added images/logo
Binary file not shown.
Binary file added images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/screenshots-vsts-arm-outputs-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions src/run.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
param (
[string] [Parameter(Mandatory = $true)]
$resourceGroupName="vsts-arm-outputs-test-rg"
)

Write-Verbose "Entering script run.ps1"

Write-Host "ResourceGroupName= $resourceGroupName"

$lastResourceGroupDeployment = Get-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName | Sort Timestamp -Descending | Select -First 1

if(!$lastResourceGroupDeployment)
{
throw "Deployment could not be found for Resource Group '$resourceGroupName'."
}

if(!$lastResourceGroupDeployment.Outputs)
{
throw "No output parameters could be found for the last deployment of Resource Group '$resourceGroupName'."
}

foreach ($key in $lastResourceGroupDeployment.Outputs.Keys){
$value = $lastResourceGroupDeployment.Outputs.Item($key).Value
Write-Host "##vso[task.setvariable variable=$key;]$value"

Write-Verbose "Updating VSTS variable '$key' to value '$value'"
}
66 changes: 66 additions & 0 deletions src/task.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"id": "584bcff2-3353-4f11-872b-6ba01267a972",
"name": "Use ARM Outputs",
"friendlyName": "Use ARM Outputs",
"description": "This task reads the output values of an ARM deployment and sets them as VSTS variable",
"helpMarkDown": "[More Information](https://github.com/keesschollaart81/vsts-arm-outputs)",
"category": "Utility",
"visibility": [
"Build",
"Release"
],
"author": "Kees Schollaart",
"version": {
"Major": 1,
"Minor": 0,
"Patch": 0
},
"demands": [
"azureps"
],
"minimumAgentVersion": "1.95.0",
"inputs": [
{
"name": "ConnectedServiceNameSelector",
"type": "pickList",
"label": "Azure Connection Type",
"required": true,
"helpMarkDown": "",
"defaultValue": "ConnectedServiceNameARM",
"options": {
"ConnectedServiceNameARM": "Azure Resource Manager"
}
},
{
"name": "ConnectedServiceNameARM",
"type": "connectedService:AzureRM",
"label": "AzureRM Subscription",
"defaultValue": "",
"required": true,
"helpMarkDown": "Select the Azure Resource Manager subscription."
},
{
"name": "resourceGroupName",
"type": "pickList",
"label": "Resource Group",
"required": true,
"helpMarkDown": "Provide the name of the resource group.",
"properties": {
"EditableOptions": "True"
}
}
],
"dataSourceBindings": [
{
"target": "resourceGroupName",
"endpointId": "$(ConnectedServiceNameARM)",
"dataSourceName": "AzureResourceGroups"
}
],
"instanceNameFormat": "Use ARM Outputs",
"execution": {
"PowerShell3": {
"target": "$(currentDirectory)\\run.ps1"
}
}
}

0 comments on commit 2952e8a

Please sign in to comment.