Current state of the workflow execution:
This Terraform configuration is capable of deploying an Azure Open AI Service and a gpt-4 model. After the deployment, it is possible to conduct a chat by using a Python script with the generated API_Key and a public Endpoint.
Create a new file inside the checked out directory of this repository, named "terraform.tfvars". The content of it can be seen in the code snippet below - there are 12 values to assign to predefined variables:
subscription_id = "<add your subscription id here>"
resource_group_name = "open-ai-test-west-europe-rg"
resource_group_location = "West Europe"
cognitive_account_name = "open-ai-test-west-europe-ca"
cognitive_account_kind = "OpenAI"
cognitive_account_sku_name = "S0"
cognitive_deployment_name = "open-ai-test-west-europe-cd"
cognitive_deployment_model_format = "OpenAI"
cognitive_deployment_model_name = "gpt-4"
cognitive_deployment_model_version = "turbo-2024-04-09"
cognitive_deployment_sku_name = "GlobalStandard"
cognitive_deployment_sku_capacity = 45
The only value to determine for your personal deployment is the "subscription_id" of your Azure subscription. You can run the following command to find the "subscription_id":
az account show
Add the subscription id as value in the first line in the "terraform.tfvars" file and save it. The "terraform.tfvars" has to be located side by side to the "main.tf", "terraform.tf" and the "variables.tf" files.
Start a new terminal, change the directory of the checked out directory of the repository.
After that, conduct the following four Terraform commands:
terraform init
terraform validate
terraform plan -out tfplan
terraform apply tfplan
This finally deploys the Azure AI Service named "open-ai-test-west-europe-ca":
and the "gpt-4" deployment "open-ai-test-west-europe-cd":
You can change the type of the deployment by adapting the following values:
cognitive_deployment_model_format = "OpenAI"
cognitive_deployment_model_name = "gpt-4"
cognitive_deployment_model_version = "turbo-2024-04-09"
cognitive_deployment_sku_name = "GlobalStandard"
Check at Azure OpenAI Service models which model fits for you also regarding your prefered region.
In that case, it's about a "gpt-4" deployment with the model version "turbo-2024-04-09".
You need to get the following information of the endpoint to establish a connection to the service:
- the API Key
- the Target URI
Explore the Details of the deployment to find that data:
Insert the mentioned information in the lines 5, respectively 6 in the file "/scripts/send_requests.py":
Afte that, call the file using Python like:
If there is no need any more, then destroy the resources using:
terraform destroy
The code of this example was partially created with the GitHub Copilot, respectively I used also the following examples and documentation of HashiCorp and Microsoft: