setting up azure sftp and python script to upload files

Pubblicato il: 12 agosto 2022
sul canale di: Adimulam Natarajan
965
3

This is a 3 part series explaining everything in simple and easy 25 steps.
I'm a best practioner to keep the enviornment safe and clean,
that added certain additional steps at the end that gave birth to part 3,
and hope you can bear with me considering the costs and benefits.

Part 1 - setting up azure sftp

1. login to portal.azure.com
2. create testRG
3. create storage a/c - sftsademo
4. LRS
5. Enable hierarchical namespace, checkbox
6. Enable SFT preview
7. wait and when finished click on goto resources button
8. click on containers
9. click on +Container
10. name: testcontainer
11. add folder public
12. SFT preview
13. Add user
14. copy SSH password
15. note down username, connection string

...

16. test connection with winscp

Part 2: file upload with python script

1. make sure you have VS Code and latest python installed
2. create a folder sftp demo
3, cd sftdemo
4. pip install pysftp
5. code .
6. create a new file main.py
7. copy the code below

import pysftp

FTP_HOST = "..."
FTP_USER = "..."
FTP_PASS = "..."

class UploadToFtp:
def __init__(self, folder, export_file):
try:
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
with pysftp.Connection(
host = FTP_HOST,
username = FTP_USER,
password = FTP_PASS,
cnopts = cnopts) as sftp:
print("Connection succesfully stablished ... ")
sftp.cwd(folder)
sftp.put(export_file)
sftp.close()
except Exception as ex:
print(ex)

8. make necessay changes to the code
9. Test your code

Part 3: cleanup azure and keep enviornment safe

Always dispose things that you don't need to keep the world slim, clean and safe

1. click on Home
2. click on testRG
3. CLICK ON 'Delete resource group'

Hope you enjoyed my video!
please do subscribe so that you get notified when I release a new video

Thanks, Adi


In questa pagina del sito puoi guardare il video online setting up azure sftp and python script to upload files della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Adimulam Natarajan 12 agosto 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 965 volte e gli è piaciuto 3 spettatori. Buona visione!