Method - Extract the substring starting from the index of "Alert Id"
, By using the substring
function.
Taken your given out put in the compose action, and being converted to string with function string(outputs('Compose_Output'))
Again, compose action using substring to start from the index of "Alert Id" with function - substring(outputs('Convert_to_String'), outputs('Compose'), 147)
Created - Set Variable "Alert Id" as required output : Alert Id*: ```/subscriptions/32476574-bf58-4703-96d9-4378327845/providers/Microsoft.AlertsManagement/alerts/629bd98a-f9b5-c79a-75b1-b807b48d0002```
Schema::
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"triggers": {
"When_a_HTTP_request_is_received": {
"type": "Request",
"kind": "Http"
}
},
"actions": {
"Compose_OutPut": {
"runAfter": {
"Alert_Id": [
"Succeeded"
]
},
"type": "Compose",
"inputs": ":azure: :alert: \n*Non-Prod Alert: RuleCpupercetange*\n*Severity*: Sev4\n*Timestamp*: 2024-10-10T17:55:18.5144302Z \n*Alert Id*: ```/subscriptions/32476574-bf58-4703-96d9-4378327845/providers/Microsoft.AlertsManagement/alerts/629bd98a-f9b5-c79a-75b1-b807b48d0002```\nClick here to find the code \n*****************************************************\n*Affected resource: W008ssaltmost* \n*Resource modified by:[email protected]*\n*****************************************************\n*Select a response:*, with interactive elements"
},
"Convert_to_String": {
"runAfter": {
"Compose_OutPut": [
"Succeeded"
]
},
"type": "Compose",
"inputs": "@string(outputs('Compose_OutPut'))"
},
"Alert_Id": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Alert Id",
"type": "string"
}
]
}
},
"Set_Variable_Alert_Id": {
"runAfter": {
"Compose_to_set_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "Alert Id",
"value": "@outputs('Compose_to_set_variable')"
}
},
"Compose": {
"runAfter": {
"Convert_to_String": [
"Succeeded"
]
},
"type": "Compose",
"inputs": "@indexOf(outputs('Convert_to_String'), 'Alert Id')\r\n"
},
"Compose_to_set_variable": {
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "Compose",
"inputs": "@substring(outputs('Convert_to_String'), outputs('Compose'), 147)\r\n"
}
},
"outputs": {},
"parameters": {
"$connections": {
"type": "Object",
"defaultValue": {}
}
}
},
"parameters": {
"$connections": {
"type": "Object",
"value": {}
}
}
}