Thursday, September 30, 2021

Update Tags to multiple Logic Apps using REST API

Tags are a crucial part of organizing your Azure resources into a taxonomy No matter how or why you use tags, it's important that you can quickly add, change, and remove those tags on your Azure resources. We can apply tags to Azure resources, resource groups, and subscriptions to logically organize them. Each tag consists of a name and a value pair.

 

In this blog let’s see how to add tags to multiple Logic Apps using REST API,

 

REST API to update tags at scope:                 

Below REST API creates or updates the tags on a resource group

https://management.azure.com/subscriptions/{subscriptionid}/resourcegroups/{resourcegroup}/providers/Microsoft.Resources/tags/default?api-version=2021-04-01

Below REST API creates or updates the tags on a subscription

https://management.azure.com/subscriptions/{subscriptionid}/providers/Microsoft.Resources/tags/default?api-version=2021-04-01

 

Joyce_Dorothy_4-1632947589692.png

 

Get the list of workflows using the below Graph API where we need to apply the tags.

https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2018-09-01-preview

 

Joyce_Dorothy_5-1632947589697.png

 

Update the retrieved workflow names to an array variable.

Note: Initialize an Integer variable (int_Index) with value ‘0’ and also initialize an Array variable(Array_workflow) with null value. Count represents the number of LogicApps workflow available in the provided subscription.

The field count can be retrieved from the raw output of ‘Get Workflows’ action. Use ‘Parse JSON’ action to retrieve only the count property.

 

Joyce_Dorothy_6-1632947589700.png

 

Within for-each loop, use the below REST API to apply tags at the workflows

https://management.azure.com/subscriptions/17374829-58e6-426f-ae3b-007191bf70b5/resourcegroups/LogicAppConsumption/providers/Microsoft.Logic/workflows/@{variables('Array_workflow')[variables('int_workflow')]}/providers/Microsoft.Resources/tags/default?api-version=2021-04-01

Note: Initialize an Integer variable (int_workflow) with value ‘0’ before using it inside the For-each loop.

 

Joyce_Dorothy_7-1632947589705.png

 

 

DisclaimerManaged Integration Service Environment connectors currently don't support tags

https://docs.microsoft.com/en-us/azure/logic-apps/add-artifacts-integration-service-environment-ise

Posted at https://sl.advdat.com/3D2admi