DEV Community

Cover image for How to deploy to Azure when you built something with AI
Michelle Duke
Michelle Duke

Posted on Edited on

How to deploy to Azure when you built something with AI

Everyone these days is vibe coding. The finance intern, the head of marketing, the random guy down the street. It's a good thing that everyone has access to build. What many people don't understand, however, is that there's a huge difference between having something running and "working on my machine" compared to having something deployed, into production, and out in the wild.

When things are running locally

When you're building an application on your own laptop—especially if you're vibe coding with an AI assistant—everything feels delightfully frictionless. You prompt, the AI writes some code, you hit run, and presto, it works on localhost:3001.

It's easy to think you're basically done at this point. After all, the app is running right there in front of you! However, running locally can be like rehearsing a play in your living room: there's no audience, you control the lighting, and you already know where all the furniture is.

When your app runs locally, a few things are happening behind the scenes that you might not even notice:

  • Your laptop is the server: Your computer's CPU, memory, and internet connection are doing all the heavy lifting. That's fine when you're the only user, and you're clicking one button at a time.
  • Your files live on your hard drive: If your app generates something—like an AI anime image saved to an /output folder—it just writes straight to your laptop's storage. Close the app, reboot your computer, open it back up tomorrow, and that file is still sitting right there.
  • Your secrets are chilling in a .env file: You probably have a .env or .env.local file sitting in your project folder holding your API keys (like OpenAI or Twilio) and passwords. Because it's only on your machine, your app reads them easily without you having to worry about random strangers on the internet seeing them.
  • Everything is on a private network: Your frontend and backend talk to each other over localhost. Nobody outside your Wi-Fi network can reach your app—which is great for testing, unless you're using external services (like Twilio webhooks) that need a public internet address to send messages back to your app.

Local development is amazing for fast iteration and testing ideas. The catch? The moment you want real humans (or external APIs) to use your app without leaving your laptop open 24/7, you have to move it to the cloud.

Everyone is vibe coding

What to think about as we move to the Cloud

Moving to the cloud isn't just "copying and pasting your code onto someone else's computer". Cloud environments work fundamentally differently from your laptop. If you deploy a vibe-coded app straight to the cloud without adjusting a few key things, it might crash, lose your data, or worse—expose your private API keys to the world.

Before we touch any Azure commands, here are the big shifts you need to plan for:

  • Containers are temporary (ephemeral storage): In the cloud, we package applications into containers. You can think of them like lightweight, self-contained boxes that hold your code and everything it needs to run. The catch is that containers are designed to be disposable. Whenever you deploy an update, or Azure restarts your container, anything saved inside the container's local folders gets completely wiped out. If your app saves generated files (such as an /app/output folder), you need persistent storage attached to the outside of the container—such as Azure Files—so your data survives restarts.
  • Never hardcode secrets or upload .env files: When your code moves to GitHub or a cloud registry, you cannot bring your local .env file along for the ride. If you accidentally commit API keys or admin passwords into your code, bots scanning GitHub will find them in seconds (and your OpenAI bill will have a very bad day). Instead, we pass secrets securely into the cloud environment at deployment time so your app can read them without them ever living in your codebase.
  • Networking and public URLs: Your cloud app needs a real, public HTTPS address so users can visit it in their browser and webhooks (like Twilio) know where to send incoming data. You also need to make sure your app is listening on the right port (for example, port 3001) and locked down properly with authentication so only authorised people can access your dashboards.
  • Dependencies and packaging: On your laptop, you probably installed Node, Python, or helper tools months ago and forgot about them. A fresh cloud container starts with nothing. You need a blueprint (ie. a Dockerfile) that tells the cloud exactly what operating system, runtimes, and packages to install so your app behaves the exact same way in Azure as it did on your machine.
  • Keeping an eye on costs: On your laptop, running an infinite loop just makes your fan spin loudly. In the cloud, you pay for compute, storage, and API calls. Knowing what resources you're spinning up—and putting sensible limits on them—keeps you from getting a surprise bill at the end of the month.

Once you wrap your head around these differences, deploying becomes way less intimidating. You're no longer blindly trusting an AI to "just put it online". Instead, you understand what's happening under the hood. There are also a lot of other things to consider when moving to the cloud, such as data usage, storage, security, and compliance. We aren't going to cover those in this tutorial/article.

How to deploy to Azure

Yes, you could just ask your AI how to do this, and it might guide you in the correct direction. However, you can't be sure if you don't know what you don't know.

Let's deploy to Azure

The first thing you'll need is an Azure account. Yes, you can't deploy to Azure without something to actually deploy to. Even those people that might have used AI and said, "my AI just did it for me". Yes, the AI went and created an Azure account on your behalf, and you probably have no idea how much money you are actually spending... maybe you should go check that 😉.

So you have an Azure account, what do you need next? The Azure CLI. Again, even if you are getting an AI agent or harness to help you do this, it will either ask you to install it or install the Azure CLI on your behalf. Once you have the CLI installed, you can now use Azure commands.

The first command you'll want to run is to authenticate and log into your account so your application—or your AI if you are asking AI to do it—knows which account we are deploying to. The command for this is:

az login --tenant <TENANT_ID>

Where do you find your Azure Tenant ID? Follow these steps:

  1. Log into the Azure Portal
  2. Click your profile picture in the top right hand corner
  3. Select "Switch Directory" How to find your Direct and Tenant ID
  4. On the screen, you should see a list of the directories you have access to on Azure Tenant Directory
  5. Scroll down to the one you want to use and look for the Tenant ID in the far right-hand column
  6. Click the "copy" icon to copy your ID to the clipboard Copy to clipboard
  7. Paste this ID into your terminal after you have typed az login --tenant

An authentication window should pop up and ask you to confirm your account details. If you have multiple subscriptions under that tenant, the terminal will also prompt you to select which subscription you want to use (you can always switch later with az account set --subscription <SUBSCRIPTION_ID>). Once you have done this, you're ready to use the Azure CLI and start running commands.

Deployment scripts

In order to deploy something to the cloud, we need to be able to run the application in a managed container rather than on our local machine. In this instance, building and deploying to Azure Container Apps. In order to do this, we need several things:

  • Azure CLI which we installed above
  • Azure account that we authenticated with above
  • A Resource Group to deploy to on Azure (think of this as a folder that holds all the Azure resources for your project in one place)
  • Persistent storage for any files you need ongoing access to (in the case of my application, I needed persistent file storage via Azure Files so the application always had access to the generated images)
  • Secrets and credentials, which are usually stored on your local machine. You'll need to give your application access to these without committing them to publicly accessible locations
  • Checks for any services you are using. For example, if you are using specific APIs or login credentials, you can have a check in your deployment script to ensure those credentials have been added before deploying:
require_env_vars \
  TWILIO_ACCOUNT_SID \
  TWILIO_AUTH_TOKEN \
  OPENAI_API_KEY \
  KIOSK_USER \
  KIOSK_PASS \
  ADMIN_USER \
  ADMIN_PASS
Enter fullscreen mode Exit fullscreen mode
  • Helper tools required to package or query your deployment. Depending on how your application and script are built, you might need extra command-line utilities installed on your machine. For example, our script queries JSON responses returned by the Azure CLI, so we need a tool that can slice, filter, map, and transform JSON data. In this case, using jq to process this information is required. Make sure you have jq installed too (or whichever tools are relevant to your application), otherwise your deployment is likely to fail. The script can enforce these as requirements right at the start:
require_command az
require_command jq
Enter fullscreen mode Exit fullscreen mode

A deploy script (deploy.sh) and a Dockerfile are super helpful for doing this all in one go. The Dockerfile packages the application and all its production dependencies into a container image. The deploy script then validates your configurations, takes in the settings we provided—such as application name, environment name, and storage account—and either creates or updates the Azure Container App.

The piece of the deployment script that builds the container image in Azure Container Registry (ACR) looks something like this:

build_image() {
  echo "Building image in ACR: $IMAGE_NAME:$IMAGE_TAG"
  az acr build \
    --registry "$AZURE_ACR_NAME" \
    --image "$IMAGE_NAME:$IMAGE_TAG" \
    .

  local digest
  digest="$(az acr repository show \
    --name "$AZURE_ACR_NAME" \
    --image "$IMAGE_NAME:$IMAGE_TAG" \
    --query digest \
    --output tsv)"
  REMOTE_IMAGE="$ACR_LOGIN_SERVER/$IMAGE_NAME@$digest"
  echo "Deploying image digest: $digest"
}
Enter fullscreen mode Exit fullscreen mode

You can also have your deployment script output helpful information for you once it finishes. For example, mine prints the live application URL, webhook URLs, and handy commands to check logs so I can easily save them for later:

print_summary() {
  local fqdn
  fqdn="$(az containerapp show \
    --name "$AZURE_CONTAINER_APP_NAME" \
    --resource-group "$AZURE_RESOURCE_GROUP" \
    --query properties.configuration.ingress.fqdn \
    --output tsv)"

  cat <<SUMMARY

Deployment complete
App URL: https://$fqdn

Twilio webhook URL (POST):    https://$fqdn/message
Stats dashboard:              https://$fqdn/stats
Output volume mount:          $AZURE_MOUNT_PATH (Azure Files: $AZURE_STORAGE_ACCOUNT/$AZURE_FILE_SHARE_NAME)

Useful checks (all human-facing routes require HTTP Basic Auth — substitute your credentials):
  curl -i -u "<KIOSK_USER>:<KIOSK_PASS>" https://$fqdn/
  curl -i -u "<ADMIN_USER>:<ADMIN_PASS>" https://$fqdn/stats
  az containerapp logs show -g $AZURE_RESOURCE_GROUP -n $AZURE_CONTAINER_APP_NAME --follow
SUMMARY
}
Enter fullscreen mode Exit fullscreen mode

Once you have your deployment script in place, you can run it to deploy to Azure Container Apps by typing:

./deploy.sh

Remember, in order to do this, you'll need:

  • A deploy script (deploy.sh)
  • Dockerfile
  • A local environment file (like .env.local) that stays on your machine (and is listed in .gitignore), so the script can read and pass your credentials to Azure securely without them ever being stored in your code. Never store your secrets and credentials inside your deploy script. Instead, your deploy script should define default configuration parameters and load your .env.local file at runtime, like this:
APP_PORT="${APP_PORT:-3001}"
DEFAULT_LOCATION="${DEFAULT_LOCATION:-australiaeast}"
DEFAULT_RESOURCE_GROUP="${DEFAULT_RESOURCE_GROUP:-rg-ai-anime-artwork}"
DEFAULT_APP_NAME="${DEFAULT_APP_NAME:-ai-anime-artwork}"
DEFAULT_ENV_NAME="${DEFAULT_ENV_NAME:-cae-ai-anime-artwork}"
DEFAULT_IMAGE_NAME="${DEFAULT_IMAGE_NAME:-ai-anime-artwork}"
DEFAULT_STORAGE_ACCOUNT="${DEFAULT_STORAGE_ACCOUNT:-}"
DEFAULT_FILE_SHARE_NAME="${DEFAULT_FILE_SHARE_NAME:-anime-output}"
DEFAULT_ENV_STORAGE_NAME="${DEFAULT_ENV_STORAGE_NAME:-anime-output-storage}"
DEFAULT_VOLUME_NAME="${DEFAULT_VOLUME_NAME:-anime-output-volume}"
DEFAULT_MOUNT_PATH="${DEFAULT_MOUNT_PATH:-/app/output}"

ENV_FILE="${ENV_FILE:-.env.local}"
IMAGE_TAG="${IMAGE_TAG:-latest}"
Enter fullscreen mode Exit fullscreen mode

Alrighty, now go ahead and run the script, and watch your container either build or update. Depending on how you've built your deployment script, you'll receive a message with all the relevant URLs and details you asked to be logged.

Remember, deployments can take a few minutes, so just be patient. Grab a cup of tea, pour a coffee, or check your emails while Azure spins everything up!

No longer trapped

And just like that, your vibe-coded app is no longer trapped on localhost. It's live in Azure, backed by persistent storage, and ready for real people (and webhooks) to use.

Vibe coding makes building faster and more accessible than ever, and understanding what happens when you take that app to the cloud ensures you stay in the driver's seat rather than blindly trusting an AI with your security or your wallet. Now that you've survived your first cloud deployment, go test those live URLs, show off what you built, and let me know in the comments what you're deploying next.

Top comments (1)

Collapse
 
devkursat profile image
Kürşat Yılmaz •

The obsession with wrapping remote APIs into multi-layered agent abstractions is creating massive hidden latency and failure cascades in production.

If you profile real-world workloads, bare-metal local inference (via direct C++ / llama.cpp or vLLM bindings) consistently beats fragile cloud wrappers on both predictability and cost. Tooling should eliminate abstraction penalties, not compound them.