azure-logic-appsazure-monitorazure-ml-pipelines

Send alert/Logic apps if Azure ML pipeline Completed with Azure ML Pipeline Outputs attached to email


I am trying to add an alert/logic apps if Azure ML pipeline completed with Azure ML Output attached in email. It looks that one of the ways is to create a monitor in the Azure Portal and other way is to create Logic apps. If i use Azure Monitor - Alerts , is there any eventtype like 'JobCompleted' ?

AmlComputeJobEvent
| where ExperimentName == 'mslearn-train-diabetes'
| where EventType == 'JobCompleted'
Can you please suggest ?

Solution

  • To get the status you can use below design:

    enter image description here

    Then:

    https://management.azure.com/subscriptions/<subid>/resourceGroups/<rgname>/providers/Microsoft.MachineLearningServices/workspaces/<workspacename>/jobs/<runidorjobid>?api-version=2024-04-01
    

    enter image description here

    Given Below roles for Logic app Manged Identity:

    AzureML Compute Operator

    AzureML Metrics Writer

    Monitoring Contributor

    then:

    enter image description here

    In Parse_Json:

    {
        "type": "object",
        "properties": {
            "id": {
                "type": "string"
            },
            "name": {
                "type": "string"
            },
            "type": {
                "type": "string"
            },
            "properties": {
                "type": "object",
                "properties": {
                    "description": {
                        "type": "string"
                    },
                    "tags": {
                        "type": "object",
                        "properties": {}
                    },
                    "properties": {
                        "type": "object",
                        "properties": {
                            "azureml.runsource": {
                                "type": "string"
                            },
                            "runSource": {
                                "type": "string"
                            },
                            "runType": {
                                "type": "string"
                            },
                            "azureml.parameters": {
                                "type": "string"
                            },
                            "azureml.continue_on_step_failure": {
                                "type": "string"
                            },
                            "azureml.continue_on_failed_optional_input": {
                                "type": "string"
                            },
                            "azureml.defaultComputeName": {
                                "type": "string"
                            },
                            "azureml.defaultDataStoreName": {
                                "type": "string"
                            },
                            "azureml.pipelineComponent": {
                                "type": "string"
                            },
                            "azureml.pipelines.stages": {
                                "type": "string"
                            }
                        }
                    },
                    "displayName": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string"
                    },
                    "experimentName": {
                        "type": "string"
                    },
                    "services": {
                        "type": "object",
                        "properties": {
                            "Tracking": {
                                "type": "object",
                                "properties": {
                                    "jobServiceType": {
                                        "type": "string"
                                    },
                                    "port": {},
                                    "endpoint": {
                                        "type": "string"
                                    },
                                    "status": {},
                                    "errorMessage": {},
                                    "properties": {},
                                    "nodes": {}
                                }
                            },
                            "Studio": {
                                "type": "object",
                                "properties": {
                                    "jobServiceType": {
                                        "type": "string"
                                    },
                                    "port": {},
                                    "endpoint": {
                                        "type": "string"
                                    },
                                    "status": {},
                                    "errorMessage": {},
                                    "properties": {},
                                    "nodes": {}
                                }
                            }
                        }
                    },
                    "computeId": {},
                    "isArchived": {
                        "type": "boolean"
                    },
                    "identity": {},
                    "componentId": {},
                    "notificationSetting": {},
                    "jobType": {
                        "type": "string"
                    },
                    "settings": {},
                    "jobs": {},
                    "inputs": {},
                    "outputs": {},
                    "sourceJobId": {}
                }
            },
            "systemData": {
                "type": "object",
                "properties": {
                    "createdAt": {
                        "type": "string"
                    },
                    "createdBy": {
                        "type": "string"
                    },
                    "createdByType": {
                        "type": "string"
                    }
                }
            }
        }
    }
    

    Output:

    enter image description here

    If you only want mail when status is completed, use condition action and in that check the body('Parse_JSON')?['properties']?['status'] is equal to Completed, In true use Outlook action.

    Alternatively, you can use below Trigger and followed Document:

    enter image description here

    then parse the json output of trigger and then send it as mail.