Upload a file in azure - python

I want to upload images in Microsoft azure through a python script and show those images in a dashboard build on django admin interface. Now, i figured since i am sending pics i should be using ftp.. So this is the code:
import ftplib
session = ftplib.FTP('server.address.com','USERNAME','PASSWORD')
file = open('kitten.jpg','rb') # file to send
session.storbinary('STOR kitten.jpg', file) # send the file
file.close() # close file and FTP
session.quit()
Now, i don't know how to setup ftp server in azure and how would i be able to fetch those images from server to my dashboard.. I don't know much about deployment so any link to do this or guide would be welcome/helpful.

It sounds like you tried to create a Django app to upload & show images via FTP on Azure WebApps.
Per my experience, the only feasible way on Azure WebApps is that reading or writing images via Kudu FTP, please refer to the offical wiki page for Kudu FTP, and set up the user name & password via Azure portal.
However, I think it's not a best practice for image showing on Azure WebApp, because normally there is concurrency limits for uploading & downloading in FTP that be not suitable for your scenario, and the storage via FTP on Azure WebApp is ready for App self, not for resource.
So my suggestion is that using Azure Blob Storage to read & write images, and Django Framework has supported for integrating with Azure Storgae via simply setup configuration. Please refer to the Django document reference for Azure Storage to knwo how to do it.

Related

How to run python programs for android app in cloud for each user

I have a python programs & classes combined together by main.py for the backend algorithms and works. I was developing the app for android using Jetpack compose in android studio.
Last week I started my research for cloud services that can run my python programs for my android.
I find that App Engine of Google Cloud Platform and Firebase. But after looking for tutorials I couldn’t find a way to work with App engine so I decided to go for Firebase.
In Firebase page, they had a service called - Cloud function. Now as per my understanding even I if I had gone with App engine, I would have used the Cloud function too.
How my app works?
My app is a social media app. I have a MongoDB server cluster in MongoDB Atlas that store every data. For authentication I had decided to go just for plain custom username & password stored encrypted on my same MongoDB server, but I was open to Firebase Authentication too. Since my app had a feed where photos, videos are stored - I needed a cloud storage for that. I found that Google Cloud storage for that.
So back to my question. Is there any service that is server-less (as I’ve very less people in my team to manage a server too) that can run Python programs for different requests from different users of my android app.
For sake of comparison, my app can be compared to Instagram without Reels!
My question is how to upload my python project, which contains different classes that are used to as algorithms for my app. It's like this, for ex., if an user goes to feed page then it has to call function in my python program that gets the feeds as per calling user's preference & followed accounts. My understanding is that I have to call this function from my android app.
I need help to find a tutorial for following things:
How to set up Firebase or App Engine & implement it in Android Studio
How to deploy my python files to firebase or App Engine for Cloud Functions
How to call this function from Android app (Kotlin + Compose) and receive in Python.
Note: I've already implemented the class that communicate with my MongoDB Atlas, So I also have functions in Python that updates the MongoDB.
Finally, how to upload the files from user input in Android app to Cloud Storage through my Python functions. And how to download files from Cloud Storage to Android app through my Python functions.

Is there a way to update just one file in microsoft azure without having to redeploy everything?

I am making a web app with python and running it on azure. It the program creates jsons and stores them. If I want to update the program is there a way to just redeploy the main python file so that it doesnt overwrite all of the josn files stored on the server?
You could update the file using FileZilla or some other FTP client. The publish profile contains the info you need. Download the publish profile from the app service overview blade, open it in Notepad, pull out the FTP address, username, and password, and import those into FileZilla. Then just drag the file across.

How can I edit the NGINX configuration on Google App Engine flexible environment?

How can I edit the Google App Engine NGINX configuration?
There doesn't seem to be much support in the Google docs in regards to the NGINX configuration for apps running in the Google App Engine flexible environment.
My app is running fine, but I get this 413 error when I try and upload an audio file (.wav or .mp3).
413 Request Entity Too Large -- nginx
My app is running Django (python 3), with Cloud Postgres SQL and Cloud Storage enabled.
I researched the error, and it seems I can set a nginx.config file so that it includes "client_max_body_size 80M" - but like I said, there is no documentation regarding how to manually config NGINX on deploy.
Any suggestions?
You should be able to create a nginx-app.conf file in the same directory as your app.yaml file. There is an example of using the nginx configuration file in a Flex environment located here: https://github.com/GoogleCloudPlatform/getting-started-php/tree/master/4-auth .
This same file is referenced in Google's documentation here: https://cloud.google.com/appengine/docs/flexible/php/runtime#customizing_nginx
Once you have that file created, you should be able to add any property you need and then rebuild your project to see the changes take effect.
So upon contacting Google Support, the suggested solution for uploading files larger than 32MB is as follows:
"The way to circumvent App Engine's 32MB limit is to send the requests directly to Cloud Storage, for instance using the resumable upload process. You can still use App Engine to serve your app, but the clientside portion of the app would be the one handling the upload to Google Cloud Storage. For this you would have your application generate a signed URL which the client can use to gain access to your Cloud Storage bucket for the purpose of uploading an image."
I went with this solution. It saves money in the end.

Using a standalone Python script on local machine to connect to and store data in GCP Datastore?

Is it possible to have a standalone Python script on my local machine connect to and store data in GCP Datastore?
I have a text file with tonnes of structured data. I just want to store it in a NoSQL GCP datastore. I don't want to have to create a web app or anything, just a python script to open the file, read each line and store it in a cloud datastore.
All the tutorials I see online start with some Flask/Jinja app on App Engine or something and I feel this is overkill.
This tutorial shows how to build a simple command-line TaskList application that stores data in the Google Cloud Datastore API. You could adapt it to read data from a text file.

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