how to pass query params to azure function when calling from action group

asked 2022-12-23T18:58:18.05+00:00
ja 26 Reputation points

HI Team,
I am trying to figure out a usecase.
We want to monitor our machine learning computes and shut them down if they cross the budget threshold.
For this, I am planning to do below things but yet not able to achieve it.

  1. create azure function which accepts a subscription and resource group as query params. It can then use MASL SDK to get the access token. And then find out the workspaces under an resource groups and then query all the computes under that workspace and shut them down.
  2. create action group which will call this function. (Not able to figure out how to pass this subscription and resource id to function app).
  3. create budget to monitor the resource group and use the action group created at step 2.

Please guide me how to update the function URL so that it accepts query param to invoke the function job.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
2,577 questions
No comments
{count} votes

2 answers

Sort by: Most helpful
  1. answered 2022-12-27T14:23:44.587+00:00
    MughundhanRaveendran-MSFT 11,606 Reputation points Microsoft Employee

    Hi @ja ,

    Thanks for posting your query in Q&A.

    In order to recommend a solution for your requirement, we need to understand the configuration of alerts. I looked into the Azure machine learning compute and the resource doesnt provide a signal related to cost/pricing. Alerts can only be triggered based on the resource's capacity utilization/errors/outage/custom logs. I am not sure if there is a way to send alert whenever a resource exceeds a particular limit. If there is a way to alert, then there is no need to pass susbcription and resource group to function app as you can only configure alerts to the function app that is present in the same subscription as that of the Machine learning compute resource. Also, a payload cannot be passed to the Function app from Alerts as it can only trigger the function.

    If there is no way to send an alert for cost/price, then you need to identify an appropriate trigger for the Function app. Maybe a timer trigger function would keep checking the resources every week/day/hour. If you are using a timer trigger, then you can list out the subscriptions associated with the service principal used by function app using the REST api. Also please refer to the Azure Machine learning compute's REST API documentation. You can figure out the cost and stop the resource using this REST api.

    Hope this helps! Feel free to reach out to me if you have any queries or concerns.

    No comments

  2. answered 2023-01-04T13:55:15.937+00:00
    Andrew Blumhardt 6,636 Reputation points Microsoft Employee

    It sounds like you want to create a solution than can be deployed as an ARM template. I think you are on the right track.

    I would start by creating a working solution in the portal before creating the ARM template(s).

    Budget alerts with an action group that runs the shutdown logic app or function. I recommend basing the budget alert on a tag that can be assigned to ML compute resources. Logic Apps will be easier if you are unfamiliar with function development.

    No comments