I’m trying to set the content type of an output blob to ‘text/json’ using imperative binding. I’m writing some Azure functions that respond to a service bus trigger by writing some data to a blob, and I need to manually define a filename for my blob output, so I’ve used imperative binding like so:
[FunctionName("Usage")]
public async Task Run([ServiceBusTrigger("Usage", "UsageFuncProc", Connection = "UsageFunctionsServiceBus")]ServiceBusReceivedMessage sbusMessage,
Binder binder)
{
...
var attributes = new Attribute[]{
new BlobAttribute($"{Utilities.GetContainerName("BlobContainerName")}/{distFormatted}{timestamp}_{entity.ClientId}_{entity.MessageType}.json", FileAccess.Write),
new StorageAccountAttribute("AzureWebJobsStorage")
};
using (var writer = await binder.BindAsync<TextWriter>(attributes)){
await writer.WriteAsync(jsonEntity);
}
This works, but by default it saves the content type as ‘application/octet-stream’ – How do I change the content type to ‘text/json’ using imperative binding?