0

I have a container instance and would like to have azure send an email when some command fails inside my azure container instance.

I was thinking of having an azure function scheduled at a certain period of time to run every 30 minutes between 00:00:00 utc and 2h utc and it would check the state of the azure container instance and if a certain string was present in the logs of that ACI and then send an email.

But I've found that azure functions don't allow to use the azure cli commands inside the azure functions and as such I cannot access the logs of my ACI with az container logs.

I also thought of using an azure batch job, but I don't know if I can create a pool with my ACI which uses an image I have created running at the abovementioned period of time and check the logs of my ACI and have azure send an email with the logs if a certain string is present in the logs.

I am new to Azure and any help on this would be appreciated.

1 Answers1

0

But I’ve found that azure functions don’t allow to use the azure cli commands inside the azure functions and as such I cannot access the logs of my ACI with az container logs.

  • As of now, Azure Functions doesn’t support the CLI Commands directly as the supported Languages are C#, F#, Java, Java Script, PowerShell, Python and Typescript shown in this MS Doc.

  • But you can use the Python Stack Azure Function where you can use the az cli commands with the help of pip packages of azure-cli.

  • To invoke the Azure resources like containers, logs using az commands, you can refer to SO thread which has a sample example of using the az cli cmdlets in Python Azure Functions given by @PeterPan.

  • You can achieve the same directly in Azure PowerShell Language Functions to invoke the container resource logs.

Pravallika KV
  • 2,415
  • 2
  • 2
  • 7