A modular application is an application composed of loosely coupled, functional units called modules, and these modules can be linked together to form a larger application. When you implement your python applications you should create such structures instead of big monoliths.
In this guide I will demonstrate how you can call python function from different folders and files (called packages). I have created a flask application which has as entrypoint the app.py file.
The solution is structured as shown below. The app folder is the root folder which contains all the code for the application. In the root hierarchy the app.py is placed along with other folders as templates, static and helpers.
As I need to create a helper function that will request data from an external API I created a file named github inside my helpers folder and I defined a function within it.
The function is very simple and returns a simple message. Code for github.py can be found below.
return "Hello from function"
In order to call your helper functions from your main app or from another python package you should first import package
For some data processing scenarios I had to create an automation that would download some files from a storage account, perform actions on them (python, custom tools) and lastly upload the processed files again in the storage account.
A high level diagram is visible below:
In order to automate this scenario I used a custom devops agent on azure devops and assigned a managed identity on this agent (virtual machine) on the storage account in order to interact with it without using credentials.
Then I only used powershell and az cli to download and upload the files on the storage account.
The three pipeline tasks that are required to perform the upload, processing, download actions can be found below.
The json object is used to download a specific file based on the requirements for example the first entry on chronological order. This is why the sort-object-descending is used.
You can use a very simple bat script in order to automatically move files from a specific windows disk to another one.
An example for this particular scenario is a case that you want to copy files from a disk to another one that resides in a datastore that is replicated. You can automatically move those files from the first disk to the second one in order to get them replicated.
All you have to do, is to create an automatic task with windows task scheduler that its action will be to run the following bat script.