PowerShell: run Python script from Azure blob storage

白昼怎懂夜的黑 提交于 2019-12-11 07:04:16

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/28258797/powershell-run-python-script-from-azure-blob-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!