Azure / Azure/azure-functions-host
How to access blobName in function.json output binding settings?
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
#### What problem would the feature you're requesting solve?
I am trying to compress images, all the uncompressed image are stored in `project-uncompressed` container. When someone uploads images to `project-uncompressed` it triggers blob created event (event triggered function). I want to store the the output images in `compressed-images-project` container and the name of blob should be same.
As of now the JSON payload of event triggered function does not contain blob name key and value. It has become impossible to use the blob name in `function.json` output binding.
Please refer to the following example:
In the code below I am using `context.bindings.outputBlob = inputBlob` to directly upload the blob using bindings settings in function.json
```
const fetch = require("node-fetch");
module.exports = async function (context, eventGridEvent, inputBlob) {
try{
context.log(typeof eventGridEvent);
context.log(eventGridEvent);
context.log(context);
context.log(typeof inputBlob);
context.log({inputBlob})
// context.bindings.outputBlob = inputBlob
}
};
```
function.json
```
{
"name": "outputBlob",
"direction": "out",
"type": "blob",
"path": "compressed-images-project/{blobName}", // How can i access the blobName here
"connection": "projectimagestore_STORAGE"
}
```
#### Describe the solution you'd like
I want a key blobName which contains the name of blob in which event was triggered.
So that I can use `"path": "compressed-images-project{blobName}"`. As of now blobName is undefined
This is how my Invocation Context looks like got this via `console.log(context)`. There are more keys present I only included few.
```
eventGridEvent: {
topic:
"/subscriptions/xxx/resourceGroups/DBA-East/providers/Microsoft.Storage/storageAccounts/projectimagestore",
subject: "/blobServices/default/containers/ipm/blobs/dvgytest-1.jpg",
eventType: "Microsoft.Storage.BlobCreated",
id: "xxx",
data: "[Object]",
dataVersion: "",
metadataVersion: "1",
eventTime: "2020-12-22T12:19:10.1723456Z",
},
inputBlob: {
Buffer:
"ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff db 00 43 00 0a 07 07 08 07 06 0a 08 08 08 0b 0a 0a 0b 0e 18 10 0e 0d 0d 0e 1d 15 16 11 ... 1528986 more bytes>",
},
},
```
#### Describe alternatives you've considered
As of now I have use `uploadStream` method under `BlobServiceClient Class` from `@azure/storage-blob` npm library
#### Additional context
I was suggested to go here for more help by this official thread: [https://github.com/Azure/azure-sdk-for-js/issues/13024](github issues)
Contributor guide
Assessment
This issue has not been assessed yet.