jdesilvio
jdesilvio

Reputation: 1854

PowerShell: run Python script from Azure blob storage

I am brand new to using PowerShell and all I want to do is create a .ps1 file that I can execute which then executes a python script from blob storage in my Azure storage account.

I think the normal execution command would simply be:

C:/test.py

or maybe set the path then:

python test.py

???

But how do I do this to execute a script stored in a blob at say:

https://StorageName.blob.core.windows.net/testing/testblob/test.py

?

And can I just save that command as a .ps1 which will kickoff the Python script when I execute the .ps1?

Thanks!

Upvotes: 1

Views: 2139

Answers (1)

David Makogon
David Makogon

Reputation: 71121

You'd first need to download your python script from your blob to local storage (whether local = VM, web/worker role instance, website instance, your laptop...). Then, once it's downloaded, you can run it.

And since you're using PowerShell: If you install the Azure PowerShell cmdlets, you can download the file from blob, using Get-AzureStorageBlobContent:

Get-AzureStorageBlobContent -Container containername -Blob blobname -Destination localFolder

More info on Get-AzureStorageBlobContent is here.

Upvotes: 2

Related Questions