How to run a Python function in Azure Function App to run a command in Azure (Windows) Virtual Machine cmd to copy a file stored in Azure blob storage?

Ruhul 1 Reputation point
2022-11-15T07:39:13.243+00:00

I am trying to write a Python function in Azure Function App to run a command in Azure (Windows) Virtual Machine command prompt that will copy input.txt file stored in Azure blob storage into output.txt file in blob again. Is there anyone who can help me with this? What should be the steps to solve this problem?

I have managed to write into files in blob directly from my python function. But I need to copy the contents of input.txt into output.txt (both stored in Azure blob storage) by running a command in my Azure virtual machine. At least any link to useful resources would be appreciated.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,605 questions
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,513 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,598 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,326 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MughundhanRaveendran-MSFT 12,446 Reputation points
    2022-11-15T13:01:08.71+00:00

    Hi @RahulK,

    Thanks for posting your query in Q&A forum.

    Instead of running the commands in the VM, you can directly copy the contents of input.txt into output.txt from the python code and run this code in Azure python function. You can use the input and output blob bindings of Azure functions or use the blob python SDK in the python code and deploy to Azure python function. This might be a simpler approach.

    If you would still like to run commands in VM from python functions, please let me know.