question

GURUVANANTHAMGuruMohan-5341 avatar image
0 Votes"
GURUVANANTHAMGuruMohan-5341 asked GURUVANANTHAMGuruMohan-5341 edited

Calling python3 runbook from another runbook in azure automation

Dear Team,

We have a function (named download_file()) which is in a python3 runbook named get_secret.py. We need to use it in an another python3 runbook called register.py.

All these runbooks are created under one of the automation accounts in Azure.

We would like to know how to call/invoke/import the function/script (get_secret.py) from register.py

Tried as per the usual method given below, but it didn't work.
In register.py

! /usr/bin/env python3

import get_secret

get_secret.download_file()


Also, imported the get_secret.py script into "Python packages" under Shared Resources in Automation Account, that too also not worked out.

The below links provide useful information for powershell but couldn't find any details for python anywhere.

https://docs.microsoft.com/en-us/azure/automation/automation-child-runbooks

Any suggestions/solutions would be very helpful.


Regards,
Guru Mohan G

azure-automation
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

tbgangav-MSFT avatar image
0 Votes"
tbgangav-MSFT answered GURUVANANTHAMGuruMohan-5341 edited

Hi @GURUVANANTHAMGuruMohan-5341,

I hope this would be helpful reference regarding python parent and child runbooks. Let me know if you have further queries with regards to it.

On the other hand, this brought up an Azure document enhancement feedback regarding this Azure document so I have created this issue so that respective content author would review and enhance the document as appropriate.

Just FYI, in general, if you have any Azure document enhancement feedback then you may click on "This page" option under "Feedback" section of the Azure document.

143420-image.png


image.png (9.2 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Dear @tbgangav-MSFT,

Thanks a lot for the quick response!

I tried importing child runbook from the main python runbook as per the above example given in the above link. (https://github.com/azureautomation/runbooks/blob/master/Utility/Python/import_child_runbook.py)

But still I'm getting the same module not found error. Please find the below snip for your reference.

143998-image.png


143959-image.png





Regards,
Guru Mohan G

0 Votes 0 ·
image.png (95.6 KiB)
image.png (48.5 KiB)
0 Votes 0 ·
image.png (61.9 KiB)