I have followed the Dapr docs and am trying to set up an azure storage queue input binding for a dotnet 6 webapi project. The webapi project works as expected when run locally but when run through dapr fails to initialze and exist with the following error. Because Dapr issues an options method ond the binding endpoint I have includeded a options endpoint of my own. I have also added cors support (commented ot now). But nothing seems to help. Has anyone encountered this before. All help welcomed.
"could not invoke OPTIONS method on input binding subscription endpoint \"Process\": %!w(*errors.errorString=&{the server closed connection before returning the first response byte. Make sure the server returns 'Connection: close' response header before closing the connection})"
.\Component\binding.yaml (redacted connection details)
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: Process
namespace: default
spec:
type: bindings.azure.storagequeues
version: v1
metadata:
- name: accountName
value: "******"
- name: accountKey
value: "******"
- name: queueName
value: "queue-name"
- name: ttlInSeconds
value: "60"
- name: decodeBase64
value: "true"
.\program.cs
var builder = WebApplication.CreateBuilder(args);
//var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
//builder.Services.AddCors(options =>
//{
// options.AddPolicy(name: MyAllowSpecificOrigins,
// policy =>
// {
// policy.WithOrigins("http://localhost", "*");
// });
//});
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
//app.UseCors(MyAllowSpecificOrigins);
app.UseAuthorization();
app.MapControllers();
app.Run();
.\Controller\TestController.cs
using Microsoft.AspNetCore.Mvc;
[ApiController]
public class TestController : ControllerBase
{
private readonly ILogger<TestController> _logger;
public TestController(ILogger<TestController> logger)
{
_logger = logger;
}
[HttpPost("Process")]
public ActionResult<string> Process([FromBody] Message message)
{
try
{
var messageJson = System.Text.Json.JsonSerializer.Serialize(message);
_logger.LogInformation($"SUCCESS: MessageArrived: {messageJson}");
return Ok(message.Id);
}
catch (Exception ex)
{
_logger.LogError(ex, "ERROR: ");
return BadRequest(ex.Message);
}
}
[HttpOptions("Process")]
public ActionResult<string> ProcessOptions([FromBody] object message)
{
return Ok();
}
}
public class Message
{
public string Id { get; set; }
public string Name { get; set; }
}
Startup command
dapr run --log-level debug --app-id dnx --app-port 7221 --dapr-http-port 3500 dotnet run test.csproj