Home > Back-end >  Editing excel file stored in Azure Storage using Azure Functions
Editing excel file stored in Azure Storage using Azure Functions

Time:04-20

I am running an Azure Function (PowerShell Core) and trying to create a new row with the values. I have loaded the ImportExcel module. But I am not sure what is the right way to reference the Excel. It is having an error that the file does not exists. Any ideas? Thanks.

Note: I don't have to use Powershell. Let me know if there are other ways as well

using namespace System.Net

param($Request)

$type = $Request.Body.type
$name = $Request.Body.name
$value = $Request.Body.value

Import-Excel -Path https://xxxxxxxxxxx.blob.core.windows.net/test/table.xlsx

CodePudding user response:

Setup the file you want to read as input binding in the host.json like:

 {
      "name": "myOutputBlob",
      "type": "blob",
      "path": "output/data.txt",
      "connection": "AzureWebJobsStorage",
      "direction": "out"
    }
  • Connection AzureWebJobsStorage should contain the Azure Storage Account connection string in local.settings.json if you're running the function locally.

  • Path value should be like container/filename.file-extension.

Push the data from your function code to this binding:

Push-OutputBinding -Name myOutputBlob -Value 'my value'

And the InputBlob should contain the blob data as an array of bytes:

foreach ($value in $inputBlob) { ... }

Refer here for more information.

  • Related