Welcome to part 4 of the “Digitize and translate your notes with Azure Cognitive Services and Python” series. In the previous posts, you explored the READ API and the Translator service and created a Flask web app that extracts and translates handwritten notes.
To find out more about previous posts, check out the links below:
Hi, I am Foteini Savvidou, a Gold Microsoft Learn Student Ambassador!
I am an undergraduate Electrical and Computer Engineering student at Aristotle University of Thessaloniki (Greece) interested in AI, cloud technologies and biomedical engineering. Always passionate about teaching and learning new things, I love helping people expand their technical skills through organizing workshops and sharing articles on my blog.
In this blog post, you will deploy your Flask web app to Azure. You will learn how to:
To complete the exercise, you will need to install:
You will also need an Azure subscription. If you don’t have one, you can sign up for an Azure free account. If you are a student, you can apply for an Azure for Students Subscription.
To host your application in Azure, you need to create an Azure App Service web app.
In the previous article, we stored the Key and Endpoint of our Cognitive Service resource in an .env
file. In App Service, we can define our keys and endpoint in App Settings and access them as environment variables.
COG_SERVICE_KEY
, COG_SERVICE_REGION
, COG_SERVICE_ENDPOINT
and ENDPOINT
and click Save to apply the settings.
The above application settings are available to your app code as environment variables and accessed using os.environ
.
key = os.environ["COG_SERVICE_KEY"]
region = os.environ["COG_SERVICE_REGION"]
endpoint = os.environ["ENDPOINT"]
COG_endpoint = os.environ["COG_SERVICE_ENDPOINT"]
.env
file and any unnecessary lines of code.
Before deploying your app, create a requirements.txt in your app’s folder and add the following libraries.
Flask
azure-cognitiveservices-vision-computervision
msrest
You can download the sample application from my GitHub repository.
There are multiple methods to deploy your Python apps to Azure App Service. In this article, I’ll show you how to deploy your application code to Azure using Visual Studio Code.
Once the deployment is complete, navigate to https://<app-name>.azurewebsites.net
and submit an image for translation to test your app.
Congratulations! You have deployed your Flask app to App Service.
In the “Digitize and translate your notes with Azure Cognitive Services and Python” series you learned how to build an intelligent web app using Flask and Azure Cognitive Services. You learned how to:
Now that you learned how to build and deploy a web app to Azure, you can enhance your app or develop a new “intelligent” app.
Here are some additional resources from Microsoft Learn:
If you have finished learning, you can delete the resource group from your Azure subscription:
Thank you for joining me in this four-part series. I hope you enjoyed the journey and learned new skills!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.