Deploying your app effectively is crucial for making it accessible to users.
- Using Azure: A powerful option for those who are already integrated into the Microsoft ecosystem or need advanced cloud services. Azure offers robust performance, scalability, and a suite of tools that are beneficial for apps requiring Microsoft-specific integrations or high availability.
The following sections provide a detailed guide on deploying your app using this platform.
To deploy your app, you will need:
- An active OpenAI account (create here).
- An OpenAI API key (create here).
-
Minimum disk space: 8GB
-
Minimum memory: 4GB
- If too many users using at the same time, it might need to be higher.
You can modify the code and deploy the container, or use our default container hosted on ghcr.io.
Prerequisites
-
Azure Account: Ensure you have an active Azure subscription.
-
Terraform: Install Terraform on your local machine. You can download it from terraform.io.
-
Azure CLI: Install Azure CLI. You can download it from docs.microsoft.com.
Steps
-
Set Up Azure CLI Login to Azure:
az loginThis will open a browser window for you to authenticate. Set the Subscription: If you have multiple subscriptions, set the one you wish to use:
az account set --subscription "your-subscription-id"Create a Directory for Your Project:
mkdir my-terraform-app cd my-terraform-app -
Use our Terraform Configuration File: Download the terraform configuration file here
-Modify the
variablesdefault field to match your desired resource configuration- az_webapp_name (change necessary. Should be unique within Global Azure) - az_rg_name (change optional) - location (change optional) - az_asp_name (change optional) -
Initialize Terraform
terraform initThis command downloads the Azure provider and sets up your workspace. -
Create an Execution Plan
Plan the Deployment:
terraform planThis command creates an execution plan, which lets you preview the changes that Terraform will make to your infrastructure. -
Apply the Execution Plan
Deploy the Resources:
terraform applyTerraform will prompt you for confirmation before making any changes. Type yes and press Enter. -
Verify Deployment
Check the Resources in Azure Portal: Go to the Azure Portal and verify that the resources have been created.
Check the deployed URL:
<az_webapp_name>.azurewebsites.net
To effectively manage user access and configuration settings in your app's deployment environment, here are some key parameters and steps for setting up your environment configuration. This guide covers how to handle these settings in Streamlit Cloud and Azure.
-
Hiding the Settings Page
Use
HIDE_SETTINGS=TRUEto conceal the Settings page. This prevents users from altering configurations that could impact the experience for other users. -
OpenAI API Key
Set
OPENAI_API_KEY="your-key"to ensure secure access to OpenAI services. This key allows interaction with OpenAI's API while keeping it confidential. -
Authentication
Enable
AUTH_ENABLED=TRUEto restrict app access to authorized users with credentials defined in a.secrets.tomlfile under the.streamlitdirectory:[passwords] user_test = "user123" ...
When deploying your app on Azure, you may need to configure user credentials as environment variables. Here's how you can accomplish this:
-
User Credentials Environment Variable
Add credentials in the format
user:password, separated by semicolons (;), to your web app's environment variables:USER_CREDENTIALS="user1:pwd1;user2:pwd2"
This setup ensures secure handling of user authentication and sensitive configurations across different deployment platforms. By using these configurations, you can maintain control over user access and protect essential settings.