Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding how to use deployment output info to README #11148

Merged
merged 4 commits into from
Aug 20, 2019

Conversation

anuragc617
Copy link
Contributor

No description provided.

@anuragc617 anuragc617 requested a review from sachinma as a code owner August 19, 2019 08:52
@anuragc617 anuragc617 changed the title Adding deployment output how to use info to README Adding how to use deployment output info to README Aug 19, 2019
@@ -73,6 +73,28 @@ The following parameters are shown when the selected action is to create or upda

* **Deployment Mode**: This specifies the [deployment mode](https://azure.microsoft.com/en-us/documentation/articles/resource-group-template-deploy) in which the Azure resources specified in the template have to be deployed. Incremental mode handles deployments as incremental updates to the resource group . It leaves unchanged resources that exist in the resource group but are not specified in the template. Complete mode deletes resources that are not in your template. [Validate mode](https://msdn.microsoft.com/en-us/library/azure/dn790547.aspx) enables you to find syntactical problems with the template before creating actual resources. By default, incremental mode is used.

### Deployment Outputs:
It is the output of the deployment object created using Azure Resource Manager templates which can be used in the subsequent tasks like Powershell and Azure CLI.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-word to "Outputs created by Azure Resource Manager template deployment. It can be used in subsequent tasks (like Azure Powershell or Azure CLI) for further processing."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

```
$var=ConvertFrom-Json '$(storageAccountName)'
$value=$var.storageAccountName.value
Write-Host "##vso[task.setvariable variable=value;]$value"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write-Host "##vso[task.setvariable variable=storageAccount;]$value"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


Example:
```
var=`echo "$(storageAccountName)" | sed -e 's/}/"\n}/g' | sed -e 's/{/{\n"/g' | sed -e 's/:/":"/g' | sed -e 's/,/",\n"/g' | sed -e 's/"}/}/g' | sed -e 's/}"/}/g' | sed -e 's/"{/{/g' | sed -e 's/\[/\[\n"/g' | sed -e 's/]/"\n]/g' | sed -e 's/"\[/\[/g' | sed -e 's/]"/]/g'`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

It is the output of the deployment object created using Azure Resource Manager templates which can be used in the subsequent tasks like Powershell and Azure CLI.

**How to use Deployment output**
The deployment output can be parsed to JSON object using "ConvertFrom-Json" PowerShell cmdlet in Poweshell task and then that object can be used in other tasks.
Copy link
Contributor

@bishal-pdMSFT bishal-pdMSFT Aug 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The deployment output can be parsed to JSON object using "ConvertFrom-Json" PowerShell cmdlet in Poweshell task and then that object can be used in other tasks.
The deployment output can be parsed to JSON object using "ConvertFrom-Json" PowerShell cmdlet in Powershell/Azure Poweshell task and then that object can be used in same task or subsequent tasks.

Write-Host "##vso[task.setvariable variable=value;]$value"
```

On linux agent if you want to use deployment output in Azure CLI task, you can avoid extra Powershell task by adding double quotes to convert it to valid JSON. This is needed because Azure CLI task on linux uses bash and the bash removes the double quotes of JSON string making it invalid JSON.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
On linux agent if you want to use deployment output in Azure CLI task, you can avoid extra Powershell task by adding double quotes to convert it to valid JSON. This is needed because Azure CLI task on linux uses bash and the bash removes the double quotes of JSON string making it invalid JSON.
On linux based agents, same technique of Powershell task can be used to create a JSON variable. However, if you want to avoid Powershell task, you can use a script similar to below which converts the Outputs to valid JSON by adding double quotes.

@@ -73,6 +73,39 @@ The following parameters are shown when the selected action is to create or upda

* **Deployment Mode**: This specifies the [deployment mode](https://azure.microsoft.com/en-us/documentation/articles/resource-group-template-deploy) in which the Azure resources specified in the template have to be deployed. Incremental mode handles deployments as incremental updates to the resource group . It leaves unchanged resources that exist in the resource group but are not specified in the template. Complete mode deletes resources that are not in your template. [Validate mode](https://msdn.microsoft.com/en-us/library/azure/dn790547.aspx) enables you to find syntactical problems with the template before creating actual resources. By default, incremental mode is used.

### Deployment Outputs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a link to this section in task.json input helptext

@anuragc617 anuragc617 merged commit aa895fa into master Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants