0

I created a adls storage account and stored here a simple python script to print hello world.script - test.py.

Created an azure runbook in powershell to run this test.py from the adls storage.

Can you please help with the code to execute the python script.

I am getting errors.

Import-Module: Line | 12 | Import-Module -Name Azure.Storage.Blob |

'Azure.Storage.Blob' was not loaded because no valid module file was
found in any module directory.
Pravash Panigrahi
  • 701
  • 2
  • 7
  • 21

1 Answers1

0

To run python script in Azure Automation, you need to create a Python runbook as below(you cannot use azure powershell runbook for this):

enter image description here

Then add the required packages:

enter image description here

Blob in azure adls storage account:

enter image description here Then use below code to get executed whats in the script:

from azure.storage.blob import BlobServiceClient

bsc = BlobServiceClient.from_connection_string('DefaultEndpointsProtocol=https;AccountName=rithwik12344455;AccountKey=ZsxpsHf9VYOS+1TLyXMpk485z+ASt/5sklA==;EndpointSuffix=core.windows.net')
Cc = bsc.get_container_client('container name')
Bc = Cc.get_blob_client('blob name ')
text = Bc.download_blob().content_as_text()
text
exec(text)

Output:

enter image description here

RithwikBojja
  • 5,069
  • 2
  • 3
  • 7