How to Send Azure OpenAI Logs and Events to Azure Log Analytics using Terraform

Guillermo Musumeci
6 min readMay 20, 2024

In this story, we will learn how to send the Azure OpenAI logs to an Azure Log Analytics Workspace using Terraform.

We will deploy an Azure OpenAI (Azure Cognitive Account) with a single ChatGPT deployment and an Azure Log Analyzer Workspace.

Then, we will configure the Azure Cognitive Account to send the logs to the Azure Log Analyzer Workspace.

For simplicity, we are deploying an Azure OpenAI without a Private Endpoint.

If you are looking for an example of deploying an Azure OpenAI with a Private Endpoint, please check the How to Deploy Azure OpenAI with Private Endpoint and ChatGPT using Terraform story.

1. Defining the Azure Provider

First, we will define the Azure authentication variables.

We will use a Service Principal with a Client Secret. Check the link below for more info about Azure authentication for Terraform: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/service_principal_client_secret

variable "azure_subscription_id" {
type = string
description = "Azure Subscription ID"
}

variable "azure_client_id" {
type = string
description = "Azure Client ID"…

--

--

Guillermo Musumeci

Certified AWS, Azure & GCP Architect | HashiCorp Ambassador | Terraform SME | KopiCloud Founder | ex-AWS | Entrepreneur | Book Author | Husband & Dad of ✌