Hello !
Thank you for posting on Microsoft Learn.
You're are right about the limitations compared to a typical python dev environment when dealing with multiple files or modules.
But you can zip them up as a module and upload them as a shared asset, or concatenate them into a single script, as you've done.
I am thinking about using Python import
semantics within a single script where you wrap your modules as classes/functions within the same file, like this:
Structure in a single runbook:
# --- module_a.py ---
class HelperA:
def do_something(self):
print("Doing something from HelperA")
# --- module_b.py ---
class HelperB:
def do_another_thing(self):
print("Doing something from HelperB")
# --- main.py ---
def main():
a = HelperA()
a.do_something()
b = HelperB()
b.do_another_thing()
if __name__ == "__main__":
main()
So, you write each module as a standalone .py
file in your dev environment and u se a CI step or local script to auto-concatenate them in the right order into one file (runbook.py
), before pushing to Azure Automation.
You can use a simple Python or shell script like:
cat module_a.py module_b.py main.py > runbook.py