I am using BlobTriggerFunction
with output binding as SignalROutput
, Now If Azure SignalR
is not configured, it throws error and runs functions again and again.
How can I make sure to execute output binding only once either failed or success. Meaning If there is AzureSignalR URL is working then it will trigger otherwise simply ignore that.
Here is sample code
Issue : If I don't have Azure SignalR
output binding failed and it retries
whole function again and in my DB FileBlob
are created multiple times.
I have tried setting retry in host.json
but it didn't help.
"retry": {
"maximumInterval" : 1
}
[Function("BlobTriggerFunction")]
[SignalROutput(HubName = "hub", ConnectionStringSetting = "AzureSignalRConnectionString")]
public static async Task<SignalRViewModel> Run([BlobTrigger("mycontainer/{name}", Connection = BlobConnectionStr")] string myBlob, string name, Uri Uri,
FunctionContext context)
{
var logger = context.GetLogger("BlobTriggerFunction");
logger.LogInformation($"C# Blob trigger function Processed blob\n Name: {name}");
var optionsBuilder = new DbContextOptionsBuilder<MyContext>();
var connectionString = Environment.GetEnvironmentVariable("ConnectionStrings");
optionsBuilder.UseSqlServer(connectionString);
var fileBlob = new FileBlob
{
Name = name,
IsDeleted = false
};
_ctx.FileBlobs.Add(fileBlob);
await _ctx.SaveChangesAsync();
return SignalRViewModel signalRVM = new SignalRViewModel()
{
Target = "hub",
UserId = data.userId,
Arguments = new[] { "default" }
};
}
Error
2022-05-18T13:50:09.899Z] Executed 'Functions.BlobTriggerFunction' (Failed, Id=f3fb531d-41d1-48eb-a266-75afb92605a9, Duration=214ms) [2022-05-18T13:50:09.902Z] System.Private.CoreLib: Exception while executing function: Functions.BlobTriggerFunction.
Microsoft.Azure.SignalR.Management: Unable to access SignalR service. No such host is known. Please make sure the endpoint or DNS setting is correct. Request Uri: https://my-test.service.signalr.net/api/v1/hubs/hub/users/0. System.Net.Http: No such host is known. System.Private.CoreLib: No such host is known.