🚀Day 5: Deploy DeepSeek AI on an Azure Windows Server via Terraform and Integrate it using the OLLAMA API

In this project, we are going to run our own local copy of the most current and trending AI model DeepSeek . Since DeepSeek is OpenSource, getting it running on our PC should be relatively easy.

NOTE: You can also run the same steps on your own personal laptop (Windows or MAC) without actually deploying any cloud VMs

STEPS

Step 1: Set Up an Azure Windows Server
Step 2: Connect to the VM
Step 3: Download and install OLLAMA
Step 4: Download and install DeepSeek
Step 5: Create a GUI using ChatBox AI

Why is this important?

Deploying DeepSeek AI using Ollama API on an Azure Windows Server is an essential project for organizations seeking to harness the power of advanced AI while retaining full control over their data and costs. This approach aligns with modern trends in hybrid cloud infrastructure, enabling innovation, compliance, and scalability.

  • On-Premises AI Deployment: By running DeepSeek locally (on a PC or Azure VM), organizations retain full control over their data and AI interactions, minimizing the risk of data leaks or breaches.

  • Compliance with Regulations: Industries with strict compliance requirements (e.g., finance, healthcare) can meet GDPR, HIPAA, or other data security regulations by keeping sensitive data on local servers.

  • API and GUI Support: By integrating Ollama’s API and ChatBox AI, organizations can create user-friendly interfaces and integrate AI capabilities into existing workflows or applications.

  • Seamless Deployment: With a straightforward setup process, technical teams can quickly bring AI models into production environments.

create folder save tf files

mkdir deepseek
cd deepseek
touch init.ps1 main.tf

Edit init.ps1 file

# Install Chocolatey silently
Set-ExecutionPolicy Bypass -Scope Process -Force
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

# Install Ollama using Chocolatey
choco install ollama -y

# Wait for the installation to complete
Start-Sleep -Seconds 5

# Pull the DeepSeek model
ollama pull deepseek-coder

# Start the Ollama API server
Start-Process -FilePath "ollama" -ArgumentList "serve" -NoNewWindow

# Wait briefly to ensure installation is complete
Start-Sleep -Seconds 30

# Pull and run the DeepSeek model
Write-Output "Running deepseek-r1:1.5b model..."
Start-Process -FilePath "ollama" -ArgumentList "run deepseek-r1:1.5b" -NoNewWindow

Edit main.tf file

provider "azurerm" {
  features {}

  subscription_id = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx"
}

resource "azurerm_resource_group" "rg" {
  name     = "rg-deepseek"
  location = "East US"
}



resource "azurerm_virtual_network" "vnet" {
  name                = "vnet-deepseek"
  address_space       = ["10.0.0.0/16"]
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
}

resource "azurerm_subnet" "subnet" {
  name                 = "subnet1"
  resource_group_name  = azurerm_resource_group.rg.name
  virtual_network_name = azurerm_virtual_network.vnet.name
  address_prefixes     = ["10.0.1.0/24"]
}

resource "azurerm_network_interface" "nic" {
  name                = "nic-deepseek"
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name

  ip_configuration {
    name                          = "internal"
    subnet_id                     = azurerm_subnet.subnet.id
    private_ip_address_allocation = "Dynamic"
    public_ip_address_id          = azurerm_public_ip.pip.id
  }
}

resource "azurerm_public_ip" "pip" {
  name                = "pip-deepseek"
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
  allocation_method   = "Static"
  sku                 = "Standard"
}


resource "azurerm_windows_virtual_machine" "vm" {
  name                = "vm-deepseek"
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
  size                = "Standard_B2ms"
  admin_username      = "azureuser"
  admin_password      = "P@ssw0rd12345!"  # Use KeyVault in production
  network_interface_ids = [
    azurerm_network_interface.nic.id,
  ]

  os_disk {
    name              = "disk-deepseek"
    caching           = "ReadWrite"
    storage_account_type = "Standard_LRS"
  }

  source_image_reference {
    publisher = "MicrosoftWindowsServer"
    offer     = "WindowsServer"
    sku       = "2022-datacenter"
    version   = "latest"
  }

  provision_vm_agent        = true
  enable_automatic_updates  = true

  winrm_listener {
    protocol = "Http"
  }

  custom_data = base64encode(file("init.ps1"))
}

resource "azurerm_network_security_group" "nsg" {
  name                = "nsg-deepseek"
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name

  security_rule {
    name                       = "RDP"
    priority                   = 1001
    direction                  = "Inbound"
    access                     = "Allow"
    protocol                   = "Tcp"
    source_port_range          = "*"
    destination_port_range     = "3389"
    source_address_prefix      = "*"
    destination_address_prefix = "*"
  }

  security_rule {
    name                       = "OLLAMA"
    priority                   = 1002
    direction                  = "Inbound"
    access                     = "Allow"
    protocol                   = "Tcp"
    source_port_range          = "*"
    destination_port_range     = "11434"
    source_address_prefix      = "*"
    destination_address_prefix = "*"
  }
}

resource "azurerm_network_interface_security_group_association" "nsg_assoc" {
  network_interface_id      = azurerm_network_interface.nic.id
  network_security_group_id = azurerm_network_security_group.nsg.id
}
terraform init
terrafrom validate
terraform plan
terraform apply -auto-approve

Step 1: Set Up an Azure Windows VM

Step 2: Connect to the VM using public ip

Step 3: Download and install OLLAMA (included in ps1 )

Go to this webpage and download the right spec based on your machine.

https://ollama.com/download/windows

Step 4: Download and install DeepSeek (included in ps1 )

Run the following command to get deepseek running. > check the version ollama --version

ollama run deepseek-r1:1.5b

Step 5: Create a GUI using ChatBox AI

To do this, go to the following url > download the windows

https://chatboxai.app/en

Choose a user , and then install it

After the installation, open the app to see the GUI.

We will need to configure it to use the Ollama API and Deepseek. To do this; click on, Settings > In Model Provider, click the dropdown menu and select ollama API > In API Host, leave as default > For Model > Click on the dropdown menu and select deepseek

Click save and run a prompt to test the model.

For the prompt, we will be asking the same question.

ASK : write a python script that outputs the numbers 1 — 10

0
Subscribe to my newsletter

Read articles from SRINIVAS TIRUNAHARI directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

SRINIVAS TIRUNAHARI
SRINIVAS TIRUNAHARI