How to host Azure Python API via Azure Data Storage - python

I have python scripts that I want to host as a web app in azure.
I want to keep the function scripts in azure data storage and host them as a python API in azure.
I want some devs to be able to change the scripts in the azure data storage and reflect the changes live without having to deploy.
How can I got about doing this?

Create Function App of Runtime Stack Python supported only in Linux Version in any Hosting Plan through Azure Portal.
Make the Continuous Deployment setting to GitHub under Deployment Center of the function app in the portal like below:
After authorizing, provide your GitHub Repository details in the same section.
Create the Azure Python Functions from VS Code and deploy to the GitHub Repository using Git Clone through Command Palette.
After that, you can deploy the functions to azure function app.
Here after publishing to azure, you'll get the Azure Functions Python Rest API.
I want some devs to be able to change the scripts in the azure data storage and reflect the changes live without having to deploy.
Whenever you or dev's make changes the changes in code through GitHub and commit the changes, then it automatically reflects in the Azure Portal Function App.
For more information, please refer this article and GitHub actions of editing the code/script files.

Related

Is there a way to create a new branch on a Google Cloud Source Repositories repo using the Python SDK?

I am using Google Cloud Source Repositories to store code for my CI/CD pipeline. What I'm building has two repos: core and clients. The core code will be built and deployed to monitor changes to a cloud storage bucket. When it detects a new customer config in the bucket, it will copy the clients code into a new branch of the clients repo named after the customer. The idea is to enable later potential tailoring for a given customer beyond the standard clients codebase.
The solution I've been considering is to have the core deploy programmatically create the branches in the the clients repo, but have come up empty handed in my research for how to do that in Google Cloud.
The only documentation that is close to what I want to do is here.
The Google Cloud SDKs do not provide a git API. However, there are python libraries that integrate with git like gitpython as one example.
Credit goes to #JohnHanley for his comment to my question for this answer.

File version different between Azure Portal and Azure Portal Kudu for the same file

Currently my Azure Function shows a different file version in the portal as compared to Kudu.
I am using Azure App Service /w Azure Functions V2 and Python 3.7.
I publish my function app using:
func azure functionapp publish <functionappname>
It successfully performs a remote build.
Now if I look at my Function App in the portal I can see the updated version of my init.py. However, when I use Kudu (Platform features > Advanced tools (Kudu)) to look into the file /home/site/wwwroot//init.py I still see the old version. Shouldn't these versions be identical?
I hope some experienced user can shed light on this.
I test it in my side, when I create a new azure function app(python) and deploy the python code from VS Code to azure portal. It will not create a "init.py" under the directory /home/site/wwwroot. In this directory, it just exists a "host.json"(shown as below).
So you can see the new version of your "init.py" after your deployment on azure portal, but it seems the old version "init.py" in the directory /home/site/wwwroot may be created by a deployment in the past or created because some other reasons in the past. I think it has nothing to do with your new deployment.

Python application logging with Azure Log Analytics

I have a small Python (Flask) application running in a Docker container.
The container orchestrator is Kubernetes, all running in Azure.
What is the best approach to set up centralized logging? (similar to Graylog)
Is it possible to get the application logs over OMS to Azure Log Analytics?
Thank you,
Tibor
I have a similar requirement. I have a continuously running Python application running in a Docker container. So far I have found that the Azure SDK for Python supports lots of integration into Azure from Python. This page might be able to help:
https://pypi.org/project/azure-storage-logging/
Here is also a package and guide how to set up Blob Storage and enable logging:
https://github.com/Azure/azure-storage-python/tree/master/azure-storage-blob

How to deploy django web application on Microsoft Azure cloud services

I have a existing django web application currently deployed on aws. I want to deploy it on Microsoft Azure by using cloud services. How to create config files for deploying web app on Azure? How to access environment variables on Azure? I am not using Visual Studio. I am developing web app in linux env and using git for code management. Please help
It sounds like you want to know which way is the best choice for deploying a django app via Git for code management on Linux, using Cloud Services or App Services on Azure.
Per my experience, I think deploying a pure web app into App Service on Azure via Git on Linux is the simplest way for you. You can refer to the offical docuemnts below to know how to do it via Azure CLI or only Git.
Deploy your first Python web app to Azure in five minutes
Local Git Deployment to Azure App Service
And there is a code sample of Django on App Service as reference that you can know how to configure it for running on Azure.
However, if your app need more powerful features & performance, using Cloud Services for your django app is also a better way than using VM directly. Also as references, please view the document Python web and worker roles with Python Tools for Visual Studio to know how to let Azure support Python & Django on Cloud Services, and you can create & deploy it via Azure portal in the browser on Linux. Meanwhile, thanks for the third party GitHub sample of Django WebRole for Cloud Service which you can refer to know how to create a cloud service project structure without PTVS for VS on Linux.
Hope it helps.
I read this post, decided the how-to guides Peter Pan posted looked good, and set off on my own. With my one business day's worth of experience if you are looking to deploy your app to Azure, start with the Marketplace Django app and go from there. Reason being the virtual environment comes with it along with the activate script needed to run the virtual environment and the web.config is setup for you. If you follow the start from scratch how-to guides, these are the hardest parts to setup correctly. Once you create the app service from the template, do a git clone of the repo to your local machine. Make a small change and push it back up by running the command below in bash.
az webapp deployment source config-local-git --name <app name> --resource-group <group name> --query url --output tsv
Use the result of the command to add the git repo as a remote source.
git remote add azure https://<ftp_credential>#<app_name>.scm.azurewebsites.net/<app_name>.git
Finally, commit your changes and deploy
git add -A
git commit -m "Test change"
git push azure remote
A couple of side notes
If you do not have your bash environment setup, you'll need to do so to use the az commands. The marketplace app does run error-free locally. I have not dug into this yet.
Good luck!

Running scripts on cloud

I'm new to cloud computing domain. Here is what I've:
1) A domain.
2) A hosting space (on HostGator).
3) A Microsoft Azure account.
And here is what I need to do:
1) Take an input file from the user using HTML.
2) Processing the input file using a Python script.
3) Returning an output file generated by the script to the user.
How do I do this? Any rough steps?
I want to implement this using Microsoft Azure.
Though HostGator supposedly supports Python 2.7, I couldn't run my scripts there and got an Internal Server Error 500.
As Azure is a cloud platform which provides a growing collection of integrated services.You can leverage Azure Web Apps to approach your need.
You can build your python project on local first, then create a Web app on Azure portal, and deploy your project to Azure Web app with Git, FTP or Visual Studio.
Here is an official reference about how to deploy python project on Azure Web app step by step.
Also, you can configure a custom domain name in Azure Web Apps, for more information you can find in Configure a custom domain name in Azure App Service

Categories