DEV Community

Jorge Castro
Jorge Castro

Posted on • Updated on

Azure Functions hacks

This is just a collection of mini-hacks to fix problems I've faced during development of Azure Functions, maybe it can help anybody out there. I'm a total newbie in Azure so if you have some insights on these issues you are welcome to show me the way of the light.

Development storage failing to start

When starting a functions app with func start locally, maybe you got it working at the beginning but suddenly you can get this cryptic unhelpful message

"There was an error performing a read operation on the Blob Storage Secret Repository. Please ensure the 'AzureWebJobsStorage' connection string is valid."

And you have no idea because the storage in dev used to work and you have your "UseDevelopmentStorage=true" in place, fear not, just go to your Server Explorer in VS, go to Storage and Blobs, there may be a couple of records there for azure-webjobs-hosts so maybe those are conflicting don't know 🤷‍♂️ for sure so just delete them and you should be good to go.

Looks like these deletions are not needed if you use files storage, use file storage for secrets storage type, in local.settings.json you have to add

"AzureWebJobsSecretStorageType": "files",

Also every time you start development with func start remember to kick off Azure Storage Emulator from program files and make sure to Start Storage Emulator from the commands or status icon in Windows

SignalR Serverless

Method not found (404)

When you start development with SignalR you may find yourself not finding the broadcast method to invoke via
await _connection.InvokeAsync("broadcast", "message" );

This maybe due the negotiate function having a [SignalRConnectionInfo(HubName = "hubname")] attribute

If you don't want to send to a hub at the beginning then just remove the hub linked connection :)

Failure to deserialize the json message

If your HubConnection.On<T> method fails to deserialize and only works with object, it may be because you need the parameterless constructor but also a public setter for your properties.

I think there is a way to pass the properties values through a constructor which is much better than having public properties but haven't looked into it.

Debug your function while running your app

Say you have your functions and app in same solution

If you are running locally using func start you can simply attach the debugger to the func.exe process and you get debugging side to side with your app :D

Top comments (0)