<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by anoopkum on Medium]]></title>
        <description><![CDATA[Stories by anoopkum on Medium]]></description>
        <link>https://medium.com/@loganoop?source=rss-57ee6f8ba673------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ga4Tj3FLFpJyrMMm_xXZdg.jpeg</url>
            <title>Stories by anoopkum on Medium</title>
            <link>https://medium.com/@loganoop?source=rss-57ee6f8ba673------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 22:14:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@loganoop/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Azure AI Foundry deployment on Terraform with Zero-Trust]]></title>
            <link>https://medium.com/@loganoop/azure-ai-foundry-deployment-on-terraform-with-zero-trust-9270ef741c75?source=rss-57ee6f8ba673------2</link>
            <guid isPermaLink="false">https://medium.com/p/9270ef741c75</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[azureaifoundry]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[anoopkum]]></dc:creator>
            <pubDate>Sun, 05 Apr 2026 22:23:59 GMT</pubDate>
            <atom:updated>2026-04-06T00:11:18.706Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*arBXZsbJf-Ra3Lu18pQT5Q.png" /></figure><p>Everyone wants to be AI-first. Almost no one wants to fix the foundations.</p><p>I kept seeing the same pattern — AI demos, LLM prototypes, RAGs tools. Impressive on the surface. But scratch underneath and you’d find API keys hardcoded in pipelines, storage accounts with public access enabled, state files committed to Git and zero observability once anything hit production.</p><p>That’s when the polished POCs fail. So I decided to build it properly.</p><p>Not a tutorial. A production-grade “Azure AI Foundry deployment on Terraform with Zero-Trust” — the kind you’d actually take into an enterprise environment, pass a security review and not regret six months later.</p><p>This post walks through every design decision, every problem I hit and every fix. The complete code is on GitHub to clone or fork: <a href="https://github.com/anoopkum/azure-ai-foundry-tf)**">https://github.com/anoopkum/azure-ai-foundry-tf</a></p><p>I will walk through fundamentals of Azure AI Foundry First</p><p>What Is Azure AI Foundry?</p><p>Azure AI Foundry (formerly Azure Machine Learning + Azure OpenAI combined) is Microsoft’s enterprise platform for building, deploying, and managing AI workloads. It gives you:</p><ul><li>- A “Hub” — the central control plane, shared across teams<br>- A “Project” — your workspace for a specific use case<br>- “AI Services” — the underlying model endpoints (GPT-4o, embeddings, etc.)<br>- Built-in connections to storage, networking, monitoring and security layers.</li><li>Security principles baked in from day one:<br>- Zero API keys — Managed Identity handles all authentication<br>- Everything behind Private Endpoints — no public internet exposure<br>- Entra ID (Azure AD) only — local auth disabled<br>- EU data residency enforced via location validation<br>- Full observability — App Insights + Log Analytics wired up properly</li></ul><p>## Architecture Overview:</p><p>Here’s what this Terraform deployment provisions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PrfdAEh8HmYo_adQ35xrgQ.png" /></figure><ul><li>Prerequisites : Before you start, you need:</li></ul><pre>bash<br># Tools<br>terraform &gt;= 1.6<br>Azure CLI (az login authenticated)<br># Azure permissions<br>Owner OR Contributor + User Access Administrator on subscription</pre><p>File Structure:</p><pre>terraform/<br>├── providers.tf # Azure provider + remote backend config<br>├── variables.tf # All input variables with validation<br>├── locals.tf # Naming conventions + common tags<br>├── main.tf # Resource Group, VNet, NSG, Monitoring<br>├── security.tf # Key Vault + Storage Account<br>├── ai-foundry.tf # Hub, Project, AI Services, RBAC<br>├── networking.tf # Private DNS Zones + Private Endpoints<br>└── outputs.tf # Resource IDs and endpoints</pre><p>Step 1 — Providers and Remote State (providers.tf):</p><p>The first design decision: two providers (azurerm and azapi), azurerm covers most resources. But for the AI Services and Hub connection azurerm doesn’t yet support it natively So I used azapi for that specific resource it talks directly to the Azure REST API.</p><pre>terraform {<br> required_version = &quot;&gt;= 1.6&quot;<br>required_providers {<br> azurerm = { source = &quot;hashicorp/azurerm&quot;; version = &quot;~&gt; 4.0&quot; }<br> azapi = { source = &quot;Azure/azapi&quot;; version = &quot;~&gt; 2.0&quot; }<br> random = { source = &quot;hashicorp/random&quot;; version = &quot;~&gt; 3.0&quot; }<br> }<br>backend &quot;azurerm&quot; {<br> resource_group_name = &quot;rg-terraform-state&quot;<br> storage_account_name = &quot;sttfstateuksouth&quot;<br> container_name = &quot;tfstate&quot;<br> key = &quot;ai-foundry.tfstate&quot;<br> }<br>}<br>provider &quot;azurerm&quot; {<br> features {<br> key_vault {<br> purge_soft_delete_on_destroy = false<br> recover_soft_deleted_key_vaults = true<br> }<br> resource_group {<br> prevent_deletion_if_contains_resources = true<br> }<br> }<br>}<br><br>#Setup the remote backend once:<br>az group create - name rg-terraform-state - location uksouth<br>az storage account create \<br> - name &lt;unique-name&gt; \<br> - resource-group rg-terraform-state \<br> - location uksouth \<br> - sku Standard_LRS<br>az storage container create - name tfstate - account-name &lt;unique-name&gt;<br>```<br>Then update `providers.tf` with your storage account name.</pre><p>Step 2 — Variables and Validation (variables.tf):</p><p>I’m a believer in validation blocks. They catch mistakes before Terraform touches Azure.</p><pre>variable &quot;project_name&quot; {<br> description = &quot;Short project identifier used in all resource names.&quot;<br> type = string<br> default = &quot;aifoundry&quot;<br> validation {<br> condition = can(regex(&quot;^[a-z0–9]{3,12}$&quot;, var.project_name))<br> error_message = &quot;project_name must be 3–12 chars, lowercase alphanumeric only.&quot;<br> }<br>}<br>variable &quot;environment&quot; {<br> type = string<br> default = &quot;dev&quot;<br> validation {<br> condition = contains([&quot;dev&quot;, &quot;staging&quot;, &quot;prod&quot;], var.environment)<br> error_message = &quot;Allowed values: dev, staging, prod.&quot;<br> }<br>}<br>variable &quot;location&quot; {<br> description = &quot;Restricted to EU regions for data residency compliance.&quot;<br> type = string<br> default = &quot;swedencentral&quot;<br> validation {<br> condition = contains([<br> &quot;swedencentral&quot;, &quot;westeurope&quot;, &quot;germanywestcentral&quot;,<br> &quot;francecentral&quot;, &quot;northeurope&quot;, &quot;italynorth&quot;<br> ], var.location)<br> error_message = &quot;Only EU regions are allowed.&quot;<br> }<br>}<br><br>#Key variables for security:<br>variable &quot;public_network_access_enabled&quot; { type = bool; default = false }<br>variable &quot;disable_local_auth&quot; { type = bool; default = true }<br>variable &quot;high_business_impact&quot; { type = bool; default = false }</pre><p><strong>disable_local_auth = true by default means Managed Identity / Entra ID authentication only. No local API keys. Ever</strong>.</p><p>Step 3 — Naming and Tagging Strategy (locals.tf)</p><pre>resource &quot;random_string&quot; &quot;suffix&quot; {<br> length = 5<br> special = false<br> upper = false<br> numeric = true<br>}<br>locals {<br> name_suffix = &quot;${var.project_name}-${var.environment}-${random_string.suffix.result}&quot;<br>rn = {<br> resource_group = &quot;rg-${local.name_suffix}&quot;<br> key_vault = &quot;kv${replace(local.name_suffix, &quot;-&quot;, &quot;&quot;)}&quot;<br> storage_account = &quot;st${replace(local.name_suffix, &quot;-&quot;, &quot;&quot;)}&quot;<br> ai_services = &quot;ais-${local.name_suffix}&quot;<br> ai_hub = &quot;hub-${local.name_suffix}&quot;<br> ai_project = &quot;proj-${local.name_suffix}&quot;<br> vnet = &quot;vnet-${local.name_suffix}&quot;<br> log_analytics = &quot;log-${local.name_suffix}&quot;<br> app_insights = &quot;appi-${local.name_suffix}&quot;<br> }<br>common_tags = merge(var.tags, {<br> Environment = var.environment<br> ManagedBy = &quot;terraform&quot;<br> Project = var.project_name<br> DataClass = &quot;eu-restricted&quot;<br> })<br>log_retention = var.environment == &quot;prod&quot; ? max(var.log_retention_days, 90) : var.log_retention_days<br>}</pre><p>The random suffix avoids naming collisions across deployments. The `common_tags` block gets merged onto every resource — Environment, ManagedBy, Project, DataClass. The log retention logic enforces a minimum of 90 days in production regardless of what someone sets in variables.</p><p>Step 4 — Core Infrastructure (main.tf)</p><p>Resource group, VNet, NSG, and monitoring:</p><pre>resource &quot;azurerm_resource_group&quot; &quot;resource_group_aifoundry&quot; {<br> name = local.rn.resource_group<br> location = var.location<br> tags = local.common_tags<br>}<br>resource &quot;azurerm_virtual_network&quot; &quot;vpc_aifoundry&quot; {<br> name = local.rn.vnet<br> location = azurerm_resource_group.resource_group_aifoundry.location<br> resource_group_name = azurerm_resource_group.resource_group_aifoundry.name<br> address_space = var.vnet_address_space<br> tags = local.common_tags<br>}<br>resource &quot;azurerm_subnet&quot; &quot;private_endpoints&quot; {<br> name = &quot;snet-private-endpoints&quot;<br> resource_group_name = azurerm_resource_group.resource_group_aifoundry.name<br> virtual_network_name = azurerm_virtual_network.vpc_aifoundry.name<br> address_prefixes = [var.subnet_private_endpoints_prefix]<br> private_endpoint_network_policies = &quot;Enabled&quot;<br>}</pre><p>Observability is wired together properly — App Insights is workspace-based and linked directly to Log Analytics:</p><pre>resource &quot;azurerm_log_analytics_workspace&quot; &quot;log_analytics&quot; {<br> name = local.rn.log_analytics<br> sku = &quot;PerGB2018&quot;<br> retention_in_days = local.log_retention # min 90 days in prod<br> tags = local.common_tags<br>}<br>resource &quot;azurerm_application_insights&quot; &quot;app_insights&quot; {<br> name = local.rn.app_insights<br> workspace_id = azurerm_log_analytics_workspace.log_analytics.id<br> application_type = &quot;web&quot;<br> tags = local.common_tags<br>}</pre><p>Step 5 — Security Layer (security.tf) Key Vault:</p><pre>resource &quot;azurerm_key_vault&quot; &quot;key_vault&quot; {<br> name = local.rn.key_vault<br> tenant_id = data.azurerm_client_config.current.tenant_id<br> sku_name = &quot;standard&quot;<br> purge_protection_enabled = true<br> soft_delete_retention_days = 90<br> rbac_authorization_enabled = true # RBAC mode, not access policies<br> public_network_access_enabled = var.public_network_access_enabled<br> network_acls {<br> default_action = var.public_network_access_enabled ? &quot;Allow&quot; : &quot;Deny&quot;<br> bypass = &quot;AzureServices&quot;<br> }<br> tags = local.common_tags<br>}</pre><p>RBAC mode instead of access policies. Purge protection on — you can’t accidentally destroy secrets permanently. 90-day soft delete.</p><p>Storage Account:</p><pre>resource &quot;azurerm_storage_account&quot; &quot;storage_account_foundry&quot; {<br> name = local.rn.storage_account<br> account_tier = &quot;Standard&quot;<br> account_replication_type = &quot;GRS&quot;<br> min_tls_version = &quot;TLS1_2&quot;<br> allow_nested_items_to_be_public = false<br> https_traffic_only_enabled = true<br> sas_policy {<br> expiration_period = &quot;00.01:00:00&quot; # SAS tokens expire in 1 hour max<br> expiration_action = &quot;Log&quot;<br> }<br> blob_properties {<br> delete_retention_policy { days = 7 }<br> cors_rule {<br> allowed_origins = [<br> &quot;https://ml.azure.com&quot;,<br> &quot;https://*.ml.azure.com&quot;,<br> &quot;https://ai.azure.com&quot;,<br> &quot;https://*.ai.azure.com&quot;<br> ]<br> # ... other CORS settings for AI Studio portal access<br> }<br> }<br> network_rules {<br> default_action = var.public_network_access_enabled ? &quot;Allow&quot; : &quot;Deny&quot;<br> bypass = [&quot;AzureServices&quot;]<br> }<br> tags = local.common_tags<br>}</pre><p>The CORS rules are important — without them, the Azure AI Studio portal can’t reach the storage account and you’ll get unexplained errors. I learned this the hard way.</p><p>Step 6 — AI Foundry Hub, Project, and Models (ai-foundry.tf)</p><p>AI Services:</p><pre>resource &quot;azurerm_ai_services&quot; &quot;azurerm_ai_foundry&quot; {<br> name = local.rn.ai_services<br> sku_name = &quot;S0&quot;<br> custom_subdomain_name = local.rn.ai_services<br> local_authentication_enabled = !var.disable_local_auth # false by default<br> public_network_access = var.public_network_access_enabled ? &quot;Enabled&quot; : &quot;Disabled&quot;<br> identity { type = &quot;SystemAssigned&quot; }<br> tags = local.common_tags<br>}<br><br>resource &quot;azurerm_ai_foundry&quot; &quot;hub&quot; {<br> name = local.rn.ai_hub<br> storage_account_id = azurerm_storage_account.storage_account_foundry.id<br> key_vault_id = azurerm_key_vault.key_vault.id<br> application_insights_id = azurerm_application_insights.app_insights.id<br> public_network_access = var.public_network_access_enabled ? &quot;Enabled&quot; : &quot;Disabled&quot;<br> high_business_impact_enabled = var.high_business_impact<br> managed_network { isolation_mode = var.managed_network_isolation_mode }<br> identity { type = &quot;SystemAssigned&quot; }<br> tags = local.common_tags<br>}<br><br>resource &quot;azurerm_ai_foundry_project&quot; &quot;project_name&quot; {<br> name = local.rn.ai_project<br> location = azurerm_ai_foundry.hub.location<br> ai_services_hub_id = azurerm_ai_foundry.hub.id<br> identity { type = &quot;SystemAssigned&quot; }<br> tags = local.common_tags<br>}</pre><p>This is where `azapi` comes in. azurerm doesn’t yet support creating the Hub ↔ AI Services connection with `authType = “AAD”`. So I used `azapi_resource` to call the Azure REST API directly:</p><pre>resource &quot;azapi_resource&quot; &quot;hub_ai_services_connection&quot; {<br> type = &quot;Microsoft.MachineLearningServices/workspaces/connections@2024–10–01&quot;<br> name = &quot;ais-connection&quot;<br> parent_id = azurerm_ai_foundry.hub.id<br> body = {<br> properties = {<br> category = &quot;AIServices&quot;<br> target = azurerm_ai_services.azurerm_ai_foundry.endpoint<br> authType = &quot;AAD&quot; # Entra ID auth - no API keys<br> isSharedToAll = true<br> metadata = {<br> ApiType = &quot;Azure&quot;<br> ResourceId = azurerm_ai_services.azurerm_ai_foundry.id<br> }<br> }<br> }<br>}</pre><p>Model Deployments:</p><pre>resource &quot;azurerm_cognitive_deployment&quot; &quot;models&quot; {<br> for_each = { for d in var.openai_deployments : d.name =&gt; d }<br> name = each.value.name<br> cognitive_account_id = azurerm_ai_services.azurerm_ai_foundry.id<br> model {<br> format = &quot;OpenAI&quot;<br> name = each.value.model_name<br> version = each.value.model_version<br> }<br> sku { name = each.value.sku_name; capacity = each.value.sku_capacity }<br>}</pre><p>Default deployments in `variables.tf`:</p><pre>variable &quot;openai_deployments&quot; {<br> default = [<br> {<br> name = &quot;gpt-4o&quot;<br> model_name = &quot;gpt-4o&quot;<br> model_version = &quot;2024–11–20&quot;<br> sku_name = &quot;DataZoneStandard&quot;<br> sku_capacity = 10<br> },<br> {<br> name = &quot;text-embedding-ada-002&quot;<br> model_name = &quot;text-embedding-ada-002&quot;<br> model_version = &quot;2&quot;<br> sku_name = &quot;Standard&quot;<br> sku_capacity = 10<br> }<br> ]<br>}</pre><p>RBAC Assignments:</p><p>This is the most important part for zero-API-key operation. The Hub’s Managed Identity needs permissions to reach storage, key vault, and AI services:</p><pre># Hub MI → Storage<br>resource &quot;azurerm_role_assignment&quot; &quot;hub_storage_blob&quot; {<br> scope = azurerm_storage_account.storage_account_foundry.id<br> role_definition_name = &quot;Storage Blob Data Contributor&quot;<br> principal_id = azurerm_ai_foundry.hub.identity[0].principal_id<br>}<br>resource &quot;azurerm_role_assignment&quot; &quot;hub_storage_file&quot; {<br> scope = azurerm_storage_account.storage_account_foundry.id<br> role_definition_name = &quot;Storage File Data Privileged Contributor&quot;<br> principal_id = azurerm_ai_foundry.hub.identity[0].principal_id<br>}<br># Hub MI → Key Vault<br>resource &quot;azurerm_role_assignment&quot; &quot;hub_kv_secrets&quot; {<br> scope = azurerm_key_vault.key_vault.id<br> role_definition_name = &quot;Key Vault Secrets User&quot;<br> principal_id = azurerm_ai_foundry.hub.identity[0].principal_id<br>}<br># Hub MI → AI Services<br>resource &quot;azurerm_role_assignment&quot; &quot;hub_cognitive&quot; {<br> scope = azurerm_ai_services.azurerm_ai_foundry.id<br> role_definition_name = &quot;Cognitive Services OpenAI User&quot;<br> principal_id = azurerm_ai_foundry.hub.identity[0].principal_id<br>}<br># Human users → Hub and Project<br>resource &quot;azurerm_role_assignment&quot; &quot;hub_contributors&quot; {<br> for_each = toset(var.hub_contributors)<br> scope = azurerm_ai_foundry.hub.id<br> role_definition_name = &quot;Azure AI Developer&quot;<br> principal_id = each.value<br>}</pre><p>Step 7 — Private Networking (networking.tf)</p><p>Six Private DNS Zones, six VNet links, five Private Endpoints:</p><pre>locals {<br> private_dns_zones = {<br> key_vault = &quot;privatelink.vaultcore.azure.net&quot;<br> storage_blob = &quot;privatelink.blob.core.windows.net&quot;<br> storage_file = &quot;privatelink.file.core.windows.net&quot;<br> ai_services = &quot;privatelink.cognitiveservices.azure.com&quot;<br> ai_hub = &quot;privatelink.api.azureml.ms&quot;<br> ai_notebook = &quot;privatelink.notebooks.azure.net&quot;<br> }<br>}<br>resource &quot;azurerm_private_dns_zone&quot; &quot;zones&quot; {<br> for_each = local.private_dns_zones<br> name = each.value<br> resource_group_name = azurerm_resource_group.resource_group_aifoundry.name<br>}<br>resource &quot;azurerm_private_dns_zone_virtual_network_link&quot; &quot;links&quot; {<br> for_each = local.private_dns_zones<br> name = &quot;link-${each.key}&quot;<br> private_dns_zone_name = azurerm_private_dns_zone.zones[each.key].name<br> virtual_network_id = azurerm_virtual_network.vpc_aifoundry.id<br> registration_enabled = false<br>}</pre><p>The DNS zones are critical — without them, traffic resolves to the public endpoint even if a private endpoint exists. DNS zone links tie the private IP resolution to your VNet.</p><p>Step 8 — Dev vs Prod Configuration:</p><p>This is one of the most practical parts. Same code, different security posture.</p><pre>| Setting | Dev | Prod |<br>| - -| - -| - -|<br>| Public network access | ✅ Enabled | ❌ Disabled |<br>| Network isolation mode | `AllowInternetOutbound` | `AllowOnlyApprovedOutbound` |<br>| High business impact | `false` | `true` |<br>| Model capacity | 10 | 50–100 |<br>| Log retention | 30 days | 90 days minimum |<br>| Access method | Direct via laptop | VPN / Bastion required<br><br>#Dev(terraform.tfvars`):<br>project_name = &quot;aifoundry&quot;<br>environment = &quot;dev&quot;<br>location = &quot;swedencentral&quot;<br>public_network_access_enabled = true<br>disable_local_auth = true<br>managed_network_isolation_mode = &quot;AllowInternetOutbound&quot;<br>hub_contributors = [&quot;&lt;your-entra-object-id&gt;&quot;]<br><br>#Prod(prod.tfvars):<br>project_name = &quot;aifoundry&quot;<br>environment = &quot;prod&quot;<br>location = &quot;swedencentral&quot;<br>public_network_access_enabled = false<br>disable_local_auth = true<br>high_business_impact = true<br>managed_network_isolation_mode = &quot;AllowOnlyApprovedOutbound&quot;<br>log_retention_days = 90</pre><p>Step 9 — Deploy It</p><pre>Get your Entra ID Object ID<br>az ad signed-in-user show - query id -o tsv<br># Add it to terraform.tfvars as hub_contributors<br># Dev deployment<br>cd terraform<br>terraform init<br>terraform plan<br>terraform apply<br># Prod deployment<br>terraform init<br>terraform plan -var-file=&quot;prod.tfvars&quot;<br>terraform apply -var-file=&quot;prod.tfvars&quot;</pre><p>Real Problems I Hit: These aren’t in the happy-path docs. They’re in the README troubleshooting section.</p><p>What’s Next: The foundation is solid. What I’d add next:</p><p>- Diagnostic Settings — wire Key Vault, Storage and AI Services logs into Log Analytics<br>- Container Registry— needed for custom model environments and fine-tuning<br>- Azure Policy assignments — enforce private endpoints and tagging at subscription level<br>- Entra ID group lookups — replace raw Object IDs with `azuread_group` data sources</p><p>Final Thought: Foundations aren’t boring work. They’re the only reason anything above them stays standing.</p><p>If you’re setting up AI infrastructure on Azure and want a starting point that doesn’t need to be rebuilt in three months — this is it.</p><p>📂 **Full code:** [github.com/anoopkum/azure-ai-foundry-tf](<a href="https://github.com/anoopkum/azure-ai-foundry-tf">https://github.com/anoopkum/azure-ai-foundry-tf</a>)</p><p>*Anoop Kumar — Lead DevOps Consultant*<br>*Open to Connect : <a href="https://www.linkedin.com/in/anoopkum/">https://www.linkedin.com/in/anoopkum/</a>*</p><p><strong>If you found this helpful, please consider giving a 👏. Appreciate you taking the time to read!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9270ef741c75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create personalized Chatbot with Azure OpenAI and Azure AI Search]]></title>
            <link>https://medium.com/@loganoop/create-personalized-chatbot-with-azure-openai-and-azure-ai-search-0f77fd10e614?source=rss-57ee6f8ba673------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f77fd10e614</guid>
            <dc:creator><![CDATA[anoopkum]]></dc:creator>
            <pubDate>Mon, 16 Jun 2025 13:36:12 GMT</pubDate>
            <atom:updated>2025-06-16T13:58:08.508Z</atom:updated>
            <content:encoded><![CDATA[<p>Nowadays, we hear a lot about generative AI (GenAI) and large language models (LLMs) from various providers for different use cases. Among them, OpenAI models such as GPT-4o and GPT-3.5 Turbo are some of the most widely used.</p><p>In this article, I will show you how to create a personalized chatbot that integrates with your own data source using OpenAI models in Azure Cloud.</p><p>Please checkout my previous article “Deploy Azure OpenAI with Terraform” for building the Cloud infrastructure for AI services with terraform.</p><p><strong>Topics</strong></p><ol><li><em>Overview of Azure AI services</em></li><li><em>Introduction to Azure AI Search and Azure OpenAI</em></li><li><em>The retrieval-augmented generation (RAG) solution and its advantages</em></li><li><em>Architecture diagram</em></li><li><em>Create Azure resources and deploy the GPT-4o model with Terraform</em></li><li><em>Adding knowledge base data to Azure AI Search for indexing</em></li><li><em>Integrating external data sources with the LLM model</em></li><li><em>Accessing the prompt and querying an external data source</em></li><li><em>Deploying the OpenAI GPT model on Azure App Service with a custom domain</em></li></ol><p><strong>1. Overview of Azure AI services:</strong></p><p>Azure offers a wide range of AI services that developers can use to build intelligent applications. These services enable you to add capabilities like vision, speech, language, and decision-making to your apps through APIs and SDKs.</p><ul><li><strong>Vision:</strong> Provides image and video analysis services</li><li><strong>Speech:</strong> Includes capabilities for speech recognition, translation and synthesis</li><li><strong>Language:</strong> Supports natural language processing (NLP) for understanding and analyzing text</li><li><strong>Decision: </strong>Offers AI services for anomaly detection and decision-making</li></ul><p><strong>2. Introduction to Azure AI Search and Azure OpenAI</strong></p><p>Azure AI Search is a powerful search platform that enables you to create a rich search experience and combine it with large language models (LLMs) to build generative AI applications using your enterprise data. Azure OpenAI provides access to models like o1-preview, o1-mini, and GPT-4o mini/turbo/audio through REST APIs, enabling content generation, summarization, semantic search, code generation, and more.</p><p>Available models in Azure OpenAI Studio include:</p><ul><li><strong>GPT-4o</strong>: Improves upon its predecessor, GPT-3.5</li><li><strong>Text-embedding-3-large/small:</strong> Converts text into numerical vectors for vector search</li><li><strong>DALL-E:</strong> Generates original images from natural language prompts</li><li><strong>Whisper:</strong> Transcribes and translates speech to text</li><li><strong>Text to Speech:</strong> Synthesizes speech from text</li></ul><p><strong>3. What is RAG (Retrieval-Augmented Generation)?</strong></p><p>RAG is an AI solution that combines search-based retrieval (like Azure AI Search) with generative models (like OpenAI) to create more accurate and context-aware responses.</p><p>Imagine a customer support chatbot that can search your company’s knowledge base through Azure AI Search and generate a response using Azure OpenAI. This helps create precise answers that are both accurate and contextually rich.</p><p><strong>Advantages of RAG:</strong></p><ul><li>Accurate responses: OpenAI generates up-to-date answers using data retrieved by Azure AI Search.</li><li>Contextual information: Azure AI Search retrieves the most relevant documents, helping OpenAI generate responses tailored to the user’s query.</li><li>Reduced hallucinations: RAG works with a base of knowledge instead of relying solely on training data, which reduces hallucinations.</li><li>Enhanced personalization: RAG models offer personalized responses based on user preferences, past interactions, and historical data.</li><li>Improved user experience: By merging search-based retrieval with generative AI, RAG delivers comprehensive answers, preventing users from sifting through multiple sources.</li></ul><p><strong>4. Architecture diagram</strong><br>The architecture diagram illustrates a workflow involving Azure Cognitive Search and Azure OpenAI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*-dPBKZ8VuT0fpeZJ.png" /></figure><p><strong>5. Creating Azure resources and deploying the GPT-4o model with Terraform</strong></p><p>You need to create the following resources using Terraform or from the Azure portal:</p><ul><li>Create a resource group: Organize your resources in Azure</li><li>Create an Azure OpenAI service: Set up GPT-4o or GPT-3.5 models</li><li>Create an Azure AI Search service: Index and retrieve documents</li><li>Create a storage account and container: For uploading documents</li></ul><p>I created the Terraform code in my GitHub repository to deploy these resources; you can clone or fork it from <a href="https://github.com/anoopkum/openai-terraform/">here</a>.</p><p>Go to the Azure Portal to see the resources deployed under Resource Group “RG-openAI-demo” as below screenshot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*V_c3xELiiux9BKAV.png" /></figure><p><strong>6. Adding knowledge base data to Azure AI Search for indexing</strong></p><p>Go to the <strong>Azure AI Search</strong> resource.</p><p>Click on the “Import Data” option and select either a sample dataset (I used the sample dataset “hotels-sample” in this blog) or your data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*knK4JoyMGtyc3GI0.png" /></figure><ul><li>Import your own data from Azure Blob Storage.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*-bRBxRC17FN-aEiN.png" /></figure><p>The following data files are uploaded in the Azure Blob Storage container named “democontainer” as knowledge base.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*Bpius35XG_pjQ-FO.png" /></figure><ul><li>Follow the prompts to configure and create an index and an indexer.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*bu6mrqMEwYM-gqqE.png" /></figure><ul><li>Go to Azure AI Search resource &gt; Search Management &gt; Indexers to verify the status.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*Mzc9E6rL89GC4Fsj.png" /></figure><p><strong>7. Integrating external data sources with the LLM model:</strong></p><ul><li>Now open Azure OpenAI resource <strong>“openai-rxt-demo” </strong>and click on Azure OpenAI Studio to access the Azure OpenAI playground.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*0mJsLuNVDGidURa3.png" /></figure><ul><li>In Azure OpenAI studio, click on “<strong>Deployments” </strong>to access the LLM models.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*W5v1EYY2i44tNqMq.png" /></figure><ul><li>Choose the GPT model deployed <strong>GPT-4o </strong>and navigate to the Playground.</li><li>In the Chat Playground, you can start interacting with the model.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*g55rE-DaJpzkiqD8.png" /></figure><ul><li>Configure important settings such as the system message (instructions for the model) and parameters (e.g., temperature, token limit) to customize how the chatbot responds.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*9EZZ0zZQSyu5EEMo.png" /></figure><ul><li>To integrate external data, select <strong>“Add Your Data”.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*mXMZG3Tv7pBpUQH4.png" /></figure><ul><li>Choose Azure AI Search as the data source.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*i9FhuVx0BGdL5sOY.png" /></figure><ul><li>Once you submit the request, the data source will be configured as Azure AI Search.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*y2pxYO7O5MnVLUJU.png" /></figure><p><strong>8. Accessing the prompt and querying the external data source:</strong></p><ul><li>In the Chat Playground, you can now ask questions that the model will answer based on the external data source.</li><li>For example, I asked the chatbot to <strong>“find me the best hotels in New York and visiting places”</strong> using the indexed knowledge base.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*OBSSW_bCwBqz6KVa.png" /></figure><ul><li>I also asked a question outside the scope of the data source, but the model was unable to provide an answer, as it can only retrieve information from the specified dataset.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*-7hOP1F29QP25eO7.png" /></figure><ul><li>When I unchecked “Limit response to your data content” in Advanced settings to allow the model to respond to queries beyond the provided data source, like I asked “tell me about the Rackspace Technology”, it responded from Internet.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*nvTKpMbkgdGGWTwm.png" /></figure><p><strong>9. Deploying the OpenAI GPT model on Azure App Service with a custom domain</strong></p><p>You can deploy the model to a web app for custom domain access. To do this, follow the steps shown in the screenshot to link it to Azure App Service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*SiCRSxTvU2eQ4MEp.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/0*Qs0udhAHu_9Hvck8.png" /></figure><p><strong><em>Note: Enabling chat history will create a Cosmos DB database to store your chat records, which may increase your costs.</em></strong></p><p>After deployment, you can access the chatbot via a custom URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*wdNnBkAQEf-mjfJC.png" /></figure><p>I hope this article helps you create a custom chatbot using Azure OpenAI and Azure AI Search. Feel free to clone the Terraform code and share any feedback or suggestions and give a clap👏 if you like the article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f77fd10e614" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Terraform AI Agent to automate IaC workflows]]></title>
            <link>https://medium.com/@loganoop/building-terraform-ai-agent-to-automate-iac-workflows-64da1734d666?source=rss-57ee6f8ba673------2</link>
            <guid isPermaLink="false">https://medium.com/p/64da1734d666</guid>
            <dc:creator><![CDATA[anoopkum]]></dc:creator>
            <pubDate>Fri, 30 May 2025 16:00:48 GMT</pubDate>
            <atom:updated>2025-06-16T13:01:24.693Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JduITESQWlzi5QUKUdGITg.png" /></figure><p>Automating infrastructure creation is a critical step for organizations embracing cloud technologies. In this article, I’ll walk you through creating an AI-powered Terraform agent that can generate, validate, and deploy Azure infrastructure code with just 3 clicks following best practices all from natural language prompts.</p><p>By the end of this guide, you’ll understand how to build a AI Agent that:</p><ol><li><strong>Converts natural language prompts into Terraform code</strong></li><li><strong>Validates the generated code using multiple tools</strong></li><li><strong>Organizes code into main.tf file</strong></li><li><strong>Deploys resources through automated GitHub action workflows</strong></li><li><strong>Securely manages credentials and secrets</strong></li><li><strong>Keep the Terraform configuration state in remote storage</strong></li></ol><p>Let’s explore how the <a href="https://github.com/anoopkum/terraform-automation/">terraform-automation repository</a> implements this solution.</p><h3>Understanding the Architecture</h3><p>Our Terraform AI Agent follows a pipeline architecture:</p><ol><li><strong>Natural Language Processing</strong>: Interprets user prompts about desired infrastructure</li><li><strong>Code Generation</strong>: Creates Terraform code for Azure resources</li><li><strong>Code Validation</strong>: Runs quality and correctness checks</li><li><strong>Resource Verification</strong>: Prevents duplicate resource creation</li><li><strong>Code Structuring</strong>: Organizes code into main.tf file</li><li><strong>Deployment Automation</strong>: Uses GitHub Actions for CI/CD</li></ol><p><strong><em>Terraform AI Agent Architecture and Workflow:</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*zAejZtkY9KGHEVwR7GWFcA.png" /></figure><h3>The Core AI Agent</h3><p>The heart of our solution is the AI agent that converts natural language into Terraform code. Looking at the repository, we can see how this is implemented in src/aiagent.py.</p><p>This agent uses OpenAI’s GPT-4o model to convert natural language prompts into structured Terraform code. The system prompt instructs the model to follow best practices and structure the code appropriately.</p><h3>User Interface Workflow</h3><p>The system features an intuitive user interface with three main action buttons that guide users through the infrastructure creation process:</p><h3>1. Generate Terraform Code Button</h3><p>When users input their infrastructure requirements as a natural language prompt, they can click the “Generate Terraform Code” button. This triggers the AI agent to:</p><ul><li><strong>Process the natural language description</strong></li><li><strong>Convert it into properly structured Terraform code</strong></li><li><strong>Organise the code into appropriate file (main.tf)</strong></li><li><strong>Verifies the absence of duplicate resources in Azure</strong></li><li><strong>Display the generated code for review</strong></li></ul><p>The generated code appears in a code editor interface where users can review and make any desired adjustments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*tQJJDc0c_I2MUXM_Bt3pUg.png" /></figure><h3>2. Validate Terraform Code Button</h3><p>After generating the code, users can click the “Validate Terraform Code” button to initiate the validation process. This button triggers:</p><ul><li><strong>Code formatting with </strong><strong>terraform fmt</strong></li><li><strong>Syntax checking with </strong><strong>terraform validate</strong></li><li><strong>Best practices verification with </strong><strong>tflint</strong></li><li><strong>Duplicate resource detection in the target Azure environment</strong></li></ul><p>The validation results appear in the interface, showing any issues that need to be addressed. Green checkmarks indicate successful validations, while red alerts highlight areas needing attention.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*jLHIgvs-mxc4m7bekxNGyg.png" /></figure><h3>3. Save &amp; Deploy Button</h3><p>Once the code passes validation, users can click the “Save &amp; Deploy” button to initiate the deployment process. This button:</p><ul><li><strong>Creates a new pull request in the GitHub repository</strong></li><li><strong>Attaches the validated Terraform code</strong></li><li><strong>Triggers the GitHub Actions workflow</strong></li><li><strong>Automates the approval and merge process</strong></li><li><strong>Deploys the infrastructure to Azure</strong></li></ul><p>The interface provides real-time status updates during the deployment process, showing the progress from plan generation to resource creation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*7IDK67_ezIvpQRxnf3eGaA.png" /></figure><h3>Terraform State Management</h3><p>A critical aspect of Terraform infrastructure management is the state file. In our architecture, the Terraform state is stored securely in Azure Blob Storage. This provides several benefits:</p><ol><li><strong>Centralized State</strong>: Team members can safely collaborate on infrastructure</li><li><strong>State Locking</strong>: Prevents concurrent modifications</li><li><strong>Versioning</strong>: Allows tracking changes over time</li><li><strong>Backup</strong>: Protects against state loss</li></ol><p>The GitHub Actions workflow initializes Terraform with backend configuration that points to the Azure Storage Account and container. The storage account access key is securely fetched from Azure Key Vault during deployment.</p><h3>Deployment Automation with GitHub Actions</h3><p>The repository uses GitHub Actions for automated deployment. The workflow in .github/workflows/deploy.yml handles the end-to-end process:</p><ol><li>Triggers when the “Save &amp; Deploy” button is clicked</li><li>Creates a pull request with the generated code</li><li>Runs automated validation checks</li><li>Generates and displays a plan of changes</li><li>Auto-approves the pull request if checks pass</li><li>Merges the code into the main branch</li><li>Deploys the infrastructure to Azure</li><li>Updates the interface with deployment status</li></ol><p>This automation significantly reduces the manual effort required to deploy infrastructure while maintaining quality and consistency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*2bo5auAn6eCYUSualUpwfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*wnpxS7tP2pSXd14Jn-2oig.png" /></figure><h3>Security Implementation</h3><p>Security is a critical aspect of our solution. The repository uses several mechanisms to keep secrets safe:</p><ol><li><strong>GitHub Secrets</strong>: Service principal credentials are stored as GitHub secrets</li><li><strong>Azure Key Vault</strong>: Sensitive information like database passwords is stored in Key Vault</li><li><strong>Secure References</strong>: Secrets are referenced securely in the pipeline</li><li><strong>Managed Identities</strong>: Used where possible to avoid credential storage</li></ol><h3>Front-End Implementation</h3><p>The front-end interface is implemented using a modern React application. Let’s look at how the core user interface component is structured:</p><p>UI Implementation (<a href="https://github.com/anoopkum/terraform-automation/blob/main/streamlit_app.py">src/streamlit_app.py</a>)</p><p>This Streamlit app implements the step-by-step workflow with the three main buttons and manages the entire process from prompt input to deployment.</p><p><strong>Live Demo of Terraform AI Agent :</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVU9irhDMWKU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVU9irhDMWKU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVU9irhDMWKU%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/db675164ca0db7ac4a3bf99306d86637/href">https://medium.com/media/db675164ca0db7ac4a3bf99306d86637/href</a></iframe><h3>Conclusion</h3><p>The Terraform AI Agent presented in this article represents a significant advancement in infrastructure automation. By combining AI-powered code generation with robust validation and automated deployment, we create a system that:</p><ol><li>Reduces the expertise required to create cloud infrastructure</li><li>Ensures consistent application of best practices</li><li>Accelerates the deployment process through an intuitive button-driven interface</li><li>Maintains security throughout the pipeline</li><li>Preserves infrastructure state for future operations</li></ol><p>The intuitive three-button interface guides users through the entire process:</p><ul><li>“Generate Terraform Code” converts natural language to infrastructure code</li><li>“Validate Terraform Code” ensures quality and correctness</li><li>“Save &amp; Deploy” automates the deployment through GitHub workflows</li></ul><p>Check out the <a href="https://github.com/anoopkum/terraform-automation">terraform-automation repository</a> to make your hands dirty and learn to create the AI agent.</p><p>If you need any help or have questions? Feel free to reach out — I’m happy to help!</p><p>👍 If you found this helpful, give it a thumbs up, support, and share it with others.<br> 📌 Follow me on Medium for more AI + DevOps content!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64da1734d666" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Azure OpenAI with Terraform]]></title>
            <link>https://medium.com/@loganoop/deploy-azure-openai-with-terraform-fcbae8650439?source=rss-57ee6f8ba673------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcbae8650439</guid>
            <dc:creator><![CDATA[anoopkum]]></dc:creator>
            <pubDate>Fri, 26 Jul 2024 17:29:57 GMT</pubDate>
            <atom:updated>2025-02-24T21:35:43.989Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_PNHqEG5hy2uwXzpp6xX2A.png" /></figure><h3>My AI Journey</h3><p>I started my journey in AI a year ago when I attended a GenAI workshop at the AWS office in London. I created my first AI project with the help of my mentor, utilising <strong>Sagemaker and the Llama 2 LLM model</strong> to create a chatbot with an <strong>external datasource</strong>. Initially, I was hesitant to dive into AI because I feared having to learn ML from scratch again, but I soon realised that with pre-trained models like LLM, you only need to provide the interface to use them.</p><p>With more experience in Azure, I started exploring Azure AI services and OpenAI. I previously wrote an article on how to deploy Azure AI services on Docker. If you’re interested, please follow me and explore my other articles. Recently, I achieved the Azure AI Certified Engineer credential and have presented few sessions within my company on Azure AI services and OpenAI.</p><p>In this article, I’ll guide you through deploying Azure OpenAI and deploy LLM Model using Terraform, <strong>I also wrote article on my company portal to Deploy RAG Solution with Azure openAI and Azure AI search and storage account to use the external datasource. Please go though the below link for complete solution &gt; </strong><a href="https://www.rackspace.com/blog/custom-chatbot-azure-openai-azure-ai-search">https://www.rackspace.com/blog/custom-chatbot-azure-openai-azure-ai-search</a></p><h3>Deploying Azure OpenAI with Terraform</h3><p>While working on OpenAI over the past few months, I found a Terraform module that helped me get started with Azure OpenAI components. Today, I will show you how to deploy Azure OpenAI using Terraform modules.</p><h3>Prerequisites</h3><ol><li><strong>Fill out the Microsoft Form</strong>: Before you can use the Azure OpenAI Service, you need to have it activated in your Azure subscription. Fill out this Microsoft form to request access with this link : <a href="https://customervoice.microsoft.com/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR7en2Ais5pxKtso_Pz4b1_xUNTZBNzRKNlVQSFhZMU9aV09EVzYxWFdORCQlQCN0PWcu">https://customervoice.microsoft.com/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR7en2Ais5pxKtso_Pz4b1_xUNTZBNzRKNlVQSFhZMU9aV09EVzYxWFdORCQlQCN0PWcu</a></li><li><strong>Set the Azure Subscription with Azure CLI</strong>: Make sure you have the Azure CLI installed. Login to your Azure account and set the subscription you want to use for deploying resources.</li></ol><pre>az login<br>az account set --subscription &lt;your-subscription-id&gt;</pre><p>3.</p><p><strong>Here is Directory structure for Terraform code</strong></p><pre>└─ terraform<br>   ├─ README.md<br>   ├─ main.tf<br>   ├─ outputs.tf<br>   ├─ terraform.tfstate<br>   ├─ provider.tf<br>   ├─ terraform.tfvars<br>   └─ variables.tf</pre><p>4. <strong>provider.tf</strong></p><p>This file specifies the required providers and their versions.</p><pre>terraform {<br>  required_providers {<br>    azurerm = {<br>      source  = &quot;hashicorp/azurerm&quot;<br>      version = &quot;3.90&quot;<br>    }<br>  }<br>}<br><br>provider &quot;azurerm&quot; {<br>  features {}<br>}</pre><p>5. <strong>main.tf</strong></p><p>This file contains the main Terraform configuration for deploying resources.</p><pre>data &quot;azurerm_client_config&quot; &quot;current&quot; {<br>}<br><br>####==========Create the Resource group======#####<br>resource &quot;azurerm_resource_group&quot; &quot;rg&quot; {<br>  name     = var.rg_name<br>  location = var.location<br>  tags     = var.tags<br>}<br><br>####==========Create AI Search Service ======#####<br>resource &quot;azurerm_search_service&quot; &quot;ai-search-service&quot; {<br>  name                = var.ai_search_name<br>  resource_group_name = azurerm_resource_group.rg.name<br>  location            = var.location<br>  sku                 = var.ai_search_sku<br><br>  local_authentication_enabled = true<br>  authentication_failure_mode  = &quot;http403&quot;<br>}<br><br>####==========Create openAI resource ======#####<br>resource &quot;azurerm_cognitive_account&quot; &quot;openai&quot; {<br>  name                          = var.openai_name<br>  location                      = var.location<br>  resource_group_name           = azurerm_resource_group.rg.name<br>  kind                          = &quot;OpenAI&quot;<br>  sku_name                      = var.openai_sku_name<br>  public_network_access_enabled = var.openai_public_network_access_enabled<br>  tags                          = var.tags<br><br>  identity {<br>    type = &quot;SystemAssigned&quot;<br>  }<br><br>  lifecycle {<br>    ignore_changes = [<br>      tags<br>    ]<br>  }<br>}<br><br>####==========Select &amp; Deploy LLM resource ======#####<br>resource &quot;azurerm_cognitive_deployment&quot; &quot;deployment&quot; {<br>  for_each             = {for deployment in var.openai_deployments: deployment.name =&gt; deployment}<br><br>  name                 = each.key<br>  cognitive_account_id = azurerm_cognitive_account.openai.id<br><br>  model {<br>    format  = &quot;OpenAI&quot;<br>    name    = each.value.model.name<br>    version = each.value.model.version<br>  }<br><br>  scale {<br>    type = &quot;Standard&quot;<br>  }<br>}<br><br>####==========Create Storage Account resource ======#####<br>resource &quot;azurerm_storage_account&quot; &quot;storage_account&quot; {<br>  name                     = var.sa_name<br>  resource_group_name      = azurerm_resource_group.rg.name<br>  location                 = var.location<br>  account_kind             = var.storage_account_kind<br>  account_tier             = var.storage_account_tier<br>  account_replication_type = var.storage_account_replication_type<br>  tags                     = var.tags<br><br>  lifecycle {<br>    ignore_changes = [<br>        tags<br>    ]<br>  }<br>}<br><br>resource &quot;azurerm_storage_container&quot; &quot;storage_container&quot; {<br>  name                  = var.container_name<br>  storage_account_name  = azurerm_storage_account.storage_account.name<br>  container_access_type = &quot;private&quot;<br>}</pre><p>6. <strong>Variables.tf</strong></p><p>This file defines the variables used in the Terraform configuration.</p><pre><br>variable &quot;location&quot; {<br>  description = &quot;Specifies the location for the resource group and all the resources&quot;<br>  default     = &quot;eastus&quot;<br>  type        = string<br>}<br><br>variable &quot;rg_name&quot; {<br>  description = &quot;Specifies the resource group name&quot;<br>  default     = &quot;&quot;<br>  type        = string<br>}<br><br>variable &quot;sa_name&quot; {<br>  description = &quot;Specifies the stoage account name&quot;<br>  default     = &quot;&quot;<br>  type        = string<br>}<br><br><br>variable &quot;storage_account_kind&quot; {<br>  description = &quot;(Optional) Specifies the account kind of the storage account&quot;<br>  default     = &quot;StorageV2&quot;<br>  type        = string<br><br>   validation {<br>    condition = contains([&quot;Storage&quot;, &quot;StorageV2&quot;], var.storage_account_kind)<br>    error_message = &quot;The account kind of the storage account is invalid.&quot;<br>  }<br>}<br><br>variable &quot;storage_account_tier&quot; {<br>  description = &quot;(Optional) Specifies the account tier of the storage account&quot;<br>  default     = &quot;Standard&quot;<br>  type        = string<br><br>   validation {<br>    condition = contains([&quot;Standard&quot;, &quot;Premium&quot;], var.storage_account_tier)<br>    error_message = &quot;The account tier of the storage account is invalid.&quot;<br>  }<br>}<br><br>variable &quot;storage_account_replication_type&quot; {<br>  description = &quot;(Optional) Specifies the replication type of the storage account&quot;<br>  default     = &quot;LRS&quot;<br>  type        = string<br><br>  validation {<br>    condition = contains([&quot;LRS&quot;, &quot;ZRS&quot;, &quot;GRS&quot;, &quot;GZRS&quot;, &quot;RA-GRS&quot;, &quot;RA-GZRS&quot;], var.storage_account_replication_type)<br>    error_message = &quot;The replication type of the storage account is invalid.&quot;<br>  }<br>}<br><br>variable &quot;container_name&quot; {<br>  description = &quot;Specifies the container name&quot;<br>  default     = &quot;&quot;<br>  type        = string<br>}<br><br><br>variable &quot;tags&quot; {<br>  description = &quot;(Optional) Specifies tags for all the resources&quot;<br>  default     = {<br>    createdWith = &quot;Terraform&quot;<br>  }<br>}<br><br><br>variable &quot;ai_search_name&quot; {<br>  description = &quot;Specifies the resource group name&quot;<br>  default     = &quot;&quot;<br>  type        = string<br>}<br><br>variable &quot;ai_search_sku&quot; {<br>  description = &quot;Specifies the resource group name&quot;<br>  default     = &quot;standard&quot;<br>  type        = string<br>}<br><br>variable &quot;openai_name&quot; {<br>  description = &quot;(Required) Specifies the name of the Azure OpenAI Service&quot;<br>  type = string<br>  default = &quot;&quot;<br>}<br><br>variable &quot;openai_sku_name&quot; {<br>  description = &quot;(Optional) Specifies the sku name for the Azure OpenAI Service&quot;<br>  type = string<br>  default = &quot;S0&quot;<br>}<br><br><br>variable &quot;openai_public_network_access_enabled&quot; {<br>  description = &quot;(Optional) Specifies whether public network access is allowed for the Azure OpenAI Service&quot;<br>  type = bool<br>  default = true<br>}<br><br>variable &quot;openai_deployments&quot; {<br>  description = &quot;(Optional) Specifies the deployments of the Azure OpenAI Service&quot;<br>  type = list(object({<br>    name = string<br>    model = object({<br>      name = string<br>      version = string<br>    })<br>    rai_policy_name = string  <br>  }))<br>  default = [<br>    {<br>      name = &quot;openai-gpt35turbo&quot;<br>      model = {<br>        name = &quot;gpt-35-turbo&quot;<br>        version = &quot;0301&quot;<br>      }<br>      rai_policy_name = &quot;&quot;<br>    }<br>  ] <br>}</pre><p>7. <strong>terraform.tfvar</strong></p><p>This file sets the values for the variables defined in variables.tf</p><pre>rg_name                = &quot;RG-openAI-demo&quot;<br>ai_search_name         = &quot;ai-search-01-demo&quot;<br>openai_name            = &quot;openai-01-demo&quot;<br>sa_name                = &quot;openaisa01demo&quot;<br>container_name         = &quot;democontainer&quot;<br>location               = &quot;eastus&quot;</pre><p>8. Run the following commands to initialise terraform, review and deploy resources via Terraform.</p><pre>terraform init<br>terraform plan<br>terraform apply</pre><p>9. Open the Azure portal and Search openAI, You can the openAI resource deployed as below. Click on GO to Azure openAI Studio to access LLM Model</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9jzb-5k453DonthYqCPWLA.png" /></figure><p>10. Once you Clicked on GO to Azure openAI Studio to access LLM Model, link will take you to the following page where you click the deployments to access the LLM Model (gpt35turbo) deployed via Terraform code. You can also deploy different LLM models like gpt4.0, Dalle3 etc from the portal to click create new deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cLD433kxPx4UmOtFKOzdaA.png" /></figure><p>11. After clicked on deployed Model (openai-chat35turbo), You can access the <strong>user prompt</strong> to use the openAI’s LLM model and ask any query as below. you can also set the different parameters like system message, temp, top p, max response etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y53szGGqDuLLTaCx3A7QGg.png" /></figure><h3>Conclusion</h3><p>By following this guide, you should be able to deploy Azure OpenAI &amp; LLM Model using Terraform successfully. This automation ensures that your deployments are consistent and repeatable. If you encounter any issues, feel free to leave a comment below.</p><p>If you find this guide helpful and successfully deploy the code, please give a thumbs up! Your feedback is greatly appreciated.</p><p>You can find the complete code on GitHub. Fork the repository to get started: <a href="https://github.com/anoopkum/openai-terraform">GitHub Repository</a>.</p><p>Happy deploying! 🚀</p><p>#Terraform #Azure #OpenAI #InfrastructureAsCode #AI #DevOps #CloudComputing #MachineLearning #AIinAzure #Automation #TechBlog #Tutorial #IaC #AzureDevOps</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcbae8650439" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Azure AI services on Docker Container.]]></title>
            <link>https://medium.com/@loganoop/deploy-azure-ai-services-on-docker-container-534ca5422de5?source=rss-57ee6f8ba673------2</link>
            <guid isPermaLink="false">https://medium.com/p/534ca5422de5</guid>
            <dc:creator><![CDATA[anoopkum]]></dc:creator>
            <pubDate>Mon, 12 Feb 2024 18:32:34 GMT</pubDate>
            <atom:updated>2024-02-12T18:32:34.178Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*OITdX3iIWXo0XcHKCwgKCA.png" /><figcaption>Deploy a Azure AI Services container image</figcaption></figure><p>This article will review how to deploy a Azure AI Services container image for text translation to an Docker Desktop Engine.</p><ul><li><strong>The Problem</strong></li><li><strong>Resolution: Packaging and deploying cognitive services APIs in a container</strong></li><li><strong>Setting up a Azure AI Services resource</strong></li><li><strong>Deployment and execution of a Text Analytics container</strong></li><li><strong>Utilising the container</strong></li><li><strong>Outcomes</strong></li><li><strong>Final Thoughts</strong></li></ul><h3><strong>The Problem:</strong></h3><p>Azure AI services hosted in Azure allow developers to concentrate on their code’s infrastructure while utilising scalable services managed by Microsoft.</p><p>However, in many cases, organisations need greater control over their service infrastructure and the data exchanged between services.</p><p>Enabling organisations to host Azure AI services in their infrastructure, such as on local Docker servers can be crucial.</p><p>The following example will illustrate how you can utilise Docker Desktop Engine to package an Azure AI services API and utilise it.</p><h3><strong>Resolution: Packaging and deploying cognitive services APIs in a container.</strong></h3><p>Most of the Azure AI services can be put into a container. This lets companies use Azure AI services on their own computers or servers. For example, they can use local Docker servers, Azure Container Instances, or Azure Kubernetes Services clusters.</p><p>When Azure AI services are in containers, they still need to talk to an Azure-based Azure AI services account for billing. But, they don’t send application data to the back-end service. This gives companies more control over how they set up their containers.</p><h3><strong>Setting up a Azure AI Services resource:</strong></h3><p>First, you’ll need to provision a <strong>Azure AI Services</strong> resource.</p><ol><li>Open the Azure portal at https://portal.azure.comAnd sign in using the Microsoft account associated with your Azure subscription.</li></ol><p>2. Select the <strong>＋Create a resource</strong> button, select <strong>Azure AI Services</strong> and create an Azure AI services multi-service account resource with the following settings:</p><p><strong>Subscription</strong>: <em>Your Azure subscription</em></p><p><strong>Resource group</strong>: <em>Choose or create a resource group</em></p><p><strong>Region</strong>: <em>Choose any available region</em></p><p><strong>Name</strong>: <em>Enter a unique name</em></p><p><strong>Pricing tier</strong>: Standard S0</p><p>3. Select the required checkboxes and create the resource.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*22eq6gYSPFof6pesT8OCzQ.png" /></figure><p>4. Wait for deployment to complete, and then view the deployment details.</p><p>5. When the resource has been deployed, go to it and view its <strong>Keys and Endpoint</strong> page. You will need the endpoint and one of the keys from this page in the next procedure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FcyIs-8ydYW07C9tRcwwlQ.png" /></figure><h3><strong>Deployment and execution of a Text Analytics container :</strong></h3><p>Install the Docker <a href="https://docs.docker.com/desktop/install/mac-install/#install-and-run-docker-desktop-on-mac">Install and run Docker Desktop on Mac</a></p><p>Install interactively Install from the command line</p><p>After downloading Docker.dmg from either the download buttons at the top of the page or from the <a href="https://docs.docker.com/desktop/release-notes/">release notes</a>, run the following commands in a terminal to install Docker Desktop in the Applications folder:</p><pre>$ sudo hdiutil attach Docker.dmg<br>$ sudo /Volumes/Docker/Docker.app/Contents/MacOS/install<br>$ sudo hdiutil detach /Volumes/Docker</pre><p>run the following command (on a single line) to deploy the language detection container to your local Docker instance, replacing <em>&lt;yourEndpoint&gt;</em> and <em>&lt;yourKey&gt;</em> with your endpoint URI and either of the keys for your Azure AI services resource.</p><p><em>docker run — rm -it -p 80:5000 — memory 12g — cpus 1 mcr.microsoft.com/azure-cognitive-services/textanalytics/language:latest Eula=accept Billing=&lt;yourEndpoint&gt; ApiKey=&lt;yourKey&gt;</em></p><p>When deployment is complete, the container will start and listen for incoming requests on localhost port 80 :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I7UKtbcViSz5ymuqfpC4aw.png" /></figure><h3><strong>Utilising the container :</strong></h3><ul><li>In the following script, modify the curl command as follows replacing &lt;localhost&gt; :</li></ul><pre>curl -X POST &quot;http://&lt;localhost&gt;:80/text/analytics/v3.0/languages&quot; -H &quot;Content-Type: application/json&quot; --data-ascii &quot;{&#39;documents&#39;:[{&#39;id&#39;:1,&#39;text&#39;:&#39;Hello world.&#39;},{&#39;id&#39;:2,&#39;text&#39;:&#39;Saludo a todo el mundo.&#39;}]}&quot;</pre><p>You don’t have to provide the Azure AI services endpoint or key here.</p><p>Next, let’s execute the script. You can use your Windows Terminal and run the following command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J-Sh-U5oCuUB6CCFP9hgXw.png" /></figure><h3>Outcomes :</h3><p>Ensure that the command returns a JSON file with details regarding the language identified in both input documents: English and Spanish</p><p><em>{“documents”:[{“id”:”1&quot;,”detectedLanguage”:{“name”:”English”,”iso6391Name”:”en”,”confidenceScore”:0.98},”warnings”:[]},{“id”:”2&quot;,”detectedLanguage”:{“name”:”Spanish”,”iso6391Name”:”es”,”confidenceScore”:1.0},”warnings”:[]}],”errors”:[],”modelVersion”:”2023–12–01&quot;}</em><strong><em>%</em></strong></p><h3>Final Thoughts :</h3><p>In this article, I’ve deployed the Azure AI services container image for text detection and translation Using Docker DesktopEngine.</p><p><em>This is my first article! Please give it a thumbs up to encourage me to write more :)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=534ca5422de5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>