• author: Dave Ebbelaar

Deploying AI Apps to the Cloud: A Step-by-Step Guide

If you are running a business, working for a client or within a company, deploying AI apps to the cloud is an essential step towards offering a complete and accessible solution to users. While setting up an AI app on a local device may be easy, deploying it to a server where users can access it can be tricky. Fortunately, in this article, we'll be showing you the step-by-step process of deploying an AI app to the cloud, specifically in Microsoft Azure. However, keep in mind that you can use this guide with any cloud platform such as AWS or the Google Cloud platform.

Why is Deploying AI Apps to the Cloud Important?

Understanding how to deploy AI apps to the cloud is crucial to delivering end-to-end solutions. As a data scientist or software engineer, possessing this skill set will help you bridge the gap between these two domains. It means you can conceive an idea and see it to completion, enabling you to sell it as a product or service to potential clients.

Setting Up a New Azure Account

Before we can begin deploying AI apps to the cloud, you need to sign up for an Azure account. You can do this by going to Microsoft Azure's website and creating a new account. If you are new to Azure, you can get up to $200 credits for free to test out the platform. Once you have created an Azure account, you'll need to create a resource group.

Creating a Resource Group

A resource group in Azure is like a top-level directory where you can store all your resources and services related to your project. You can create a resource group by:

  1. Logging into your new Azure account.
  2. Clicking on "Resource groups" from the Azure dashboard.
  3. Clicking on the "+Add" icon to create a new resource group.
  4. Naming the resource group appropriately.
  5. Selecting the region closest to your location.

Once you have created the resource group, you can now begin adding resources to your project.

Creating an App Service

An app service is a managed platform that allows you to deploy, build and scale web applications conveniently on Azure. For our purposes, we need to create a web app server. Here's how to create an app service in Azure:

  1. Click on "Create a resource."
  2. Search for "app service" and select the "Web App" option.
  3. Enter a unique name for your new app service.
  4. Choose the appropriate Resource Group where you want to add the app service.
  5. Choose the appropriate runtime Python version.
  6. Select the appropriate region closest to your location.
  7. Create a pricing plan for your server.

Once you have created your app service, you can now begin deploying your AI app to the cloud.

Deploying Your AI App

To deploy your AI app, you'll need to follow these steps:

  1. Create a GitHub repository where you'll push your code changes.
  2. Clone the repository to your local machine where your AI app code is stored.
  3. Make the necessary code changes to ensure it can be deployed to your app service.
  4. Commit your changes to the local repository.
  5. Push the changes to the remote GitHub repository.

Once you have set up the repository, every time you push changes to the repository, Azure will automatically deploy the new version of your app to the app service.


As we've seen, deploying AI apps to the cloud requires a series of well-defined steps that anyone with the right skills can follow. In this guide, we've shown you how to create an Azure account, set up a resource group, create an app service, and deploy your AI app to the cloud. But this is just the beginning; there is much more to learn about the possibilities that the cloud offers. With practice, you'll quickly become an expert in deploying AI apps to the cloud, opening up a world of opportunities for your business or client.

Deploying an Azure Web App via GitHub

In this tutorial, we will walk you through the steps of deploying an Azure Web App via GitHub. We will cover how to connect and authorize your GitHub repository with Azure and create a workflow to enable automated deployments.

Understanding Azure Components

Before diving into the details of deploying through GitHub, it is essential to understand the basic components of Azure. Azure has app servers and app service plans that work together to host web applications. App service plans provide computing resources, while app servers run the web applications.

Deploying via GitHub

Deploying via GitHub is convenient because it allows you to make changes locally, commit them to GitHub, and trigger an action to redeploy the application on the web server. Here are the steps to initiate the deployment process:

  1. Go to the Azure Deployment Center within your web app.
  2. Select the source and choose GitHub.
  3. Clone the repository and push it to your GitHub account.
  4. Delete the entire ".GitHub" folder, which holds the workflow.
  5. Authorize your account and select your organization, repository, and branch.
  6. Create a workflow file, which will trigger the deployment after committing and pushing.
  7. Hit save and wait while Azure adds the ".GitHub" directory with the workflows to your repository.
  8. Pull everything into your project.

Updating the Startup Text File

To instruct Azure about what to do when starting the app, we create a startup.txt file in the root directory of your repository. It should contain the following command:


Ensure that the file points to the Flask app with the correct path and directory name.

Updating the Azure Configuration

An essential step in deploying an Azure web app is updating the Azure configuration with keys and secrets. When working locally, use the ".env" file to store the application secrets, but when deployed on Azure, it is necessary to update the application settings manually.

To update the Azure configuration, follow these steps:

  1. Go to the Configuration tab and then General Settings.
  2. Update the startup command with "startup.txt."
  3. Go to Application Settings and add new settings for the secrets.
  4. Ensure that all keys are included as environment variables and stored securely.

Updating the Workflow File

Finally, we will update the GitHub Actions workflow file to enable automated deployments. We will log in using the Azure CLI and the service principle. Here are the steps:

  1. Update your workflow file with the code to log in via the Azure CLI.
  2. Create a service principle and replace your subscription ID with your actual subscription ID.

By following these steps, you can deploy an Azure web app seamlessly using GitHub.

Creating a Surface Principle and Updating Slack App Event Subscription

In this section, we will cover the final steps to deploy the Slackbot application to Azure.

Creating a Surface Principle

Firstly, we need to create a surface principle which is a security layer that protects our applications. To create it, we will take the following steps:

  1. Replace your subscription ID with your actual subscription ID in the code provided.
  2. Open the Azure Cloud shell by clicking on the shell icon and select the subscription and create a storage.
  3. Use Azure CLI command line interface to interact with our subscription using bash.
  4. Run the command copied previously, but update your subscription ID and the name for your service principle.
  5. Copy the whole Json response and keep it secure as this information should be private.

Once you have created the service principle, you need to store this information in a variable called Azure credentials in GitHub.

Updating Slack App Event Subscription

After we have added the service principle to the workflow and updated the secrets in GitHub, it's time to update the Python file. The changes we make include:

  1. Set the host to listen to all incoming connections and switch the port to 8000.
  2. Add the verification for enhanced security through two functions: verify slack request and require slack verification.
  3. Use a decorator to add requires slack verification to the Slack events.

Once we have updated the Python file, the final step is to update the Slack app event subscription.

We need to replace the ngrok URL with the real URL and endpoint of our application.

To complete this deployment, we commit and push the changes to GitHub, triggers the deployment action, and reference the Azure log stream for debugging.

Overall, these deployment steps may look complicated, but they are critical for adding an extra layer of security to the application.

Deploying an AI App to the Cloud using Python Flask and Azure

In this tutorial, we went over the step-by-step process of deploying an AI app to the cloud using Python Flask and Azure. We updated the Python file, deployed everything, and updated the Slack app event subscription.

To update the Slack app event subscription, follow the steps below:

  1. Check the default domain on your web app. The default domain will be the name of your app followed by ".azurewebsites.net".
  2. Copy the default domain and paste it into the Slack app event subscription.
  3. Add a new URL and include the endpoint (e.g. "/slack/events").
  4. Verify the URL and if it's correct, you should get a green check.
  5. Subscribe to both events and event names mentioned in the tutorial.
  6. Save the changes and test if everything is live.

If you followed all the steps, your Flask app should be running, and your Slack bot is listening to the updated event subscription URL. You can validate and test everything in Slack by messaging Emma and asking her questions.

Additionally, you can configure new functions for Emma, your personal assistant, to follow. We will explore this concept in detail in future videos. This is a valuable skill that can be used to implement end-to-end solutions for clients, teams, or as a product.

If you want to take your skills to the next level and find potential clients to work with, you should check out Data Freelancer, a Mastermind group of data professionals working on profit, fulfillment, and freedom through freelancing. We can help you set up a six-figure freelancing business in data.

Please don't forget to hit the like and subscribe button to support us and receive notifications for future content. Thank you for watching, and see you in the next one.

Previous Post

How GPT Engineer is Revolutionizing Code Writing

Next Post

Using GPT-0 to Future-Proof Your Content

About The auther

New Posts

Popular Post