in src/Microsoft.Azure.WebJobs.Extensions.Dapr/Services/DaprServiceClient.cs [222:250]
public async Task PublishEventAsync(
string? daprAddress,
string name,
string topicName,
JsonElement? payload,
CancellationToken cancellationToken)
{
try
{
this.EnsureDaprAddress(ref daprAddress);
var req = new HttpRequestMessage(HttpMethod.Post, $"{daprAddress}/v1.0/publish/{name}/{topicName}");
if (payload != null)
{
req.Content = new StringContent(payload?.GetRawText(), Encoding.UTF8, "application/json");
}
await this.daprClient.SendAsync(this.publishOutputLogger, req, cancellationToken);
}
catch (Exception ex)
{
if (ex is DaprException || ex is DaprSidecarNotPresentException)
{
throw;
}
throw new DaprException(HttpStatusCode.InternalServerError, ErrorCodes.ErrDaprRequestFailed, "An error occurred while publishing event.", ex);
}
}