My Azure function successfully retrieves eventhub events on a home network, but not from inside my company network. Error received as follows:
A connection attempt failed because the connected party did not properly respond >after a period of time, or established connection failed because connected host >has failed to respond
By default, the eventhub trigger uses AMQ protocol, which is blocked by our firewall. I'd like to change the transport type to use https over port 443.
Code generated by Visual Studio 2022 (works fine from home network)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.EventHubs;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
namespace EventHubConsumers
{
public class Function1
{
[FunctionName("Function1")]
public async Task Run([EventHubTrigger("test1", Connection = "ConnectionToEventHubReceived")] EventData[] events, ILogger log)
{
var exceptions = new List<Exception>();
foreach (EventData eventData in events)
{
try
{
string messageBody = Encoding.UTF8.GetString(eventData.Body.Array, eventData.Body.Offset, eventData.Body.Count);
// Replace these two lines with your processing logic.
log.LogInformation($"C# Event Hub trigger function processed a message: {messageBody}");
await Task.Yield();
}
catch (Exception e)
{
// We need to keep processing the rest of the batch - capture this exception and continue.
// Also, consider capturing details of the message that failed processing so it can be processed again later.
exceptions.Add(e);
}
}
// Once processing of the batch is complete, if any messages in the batch failed processing throw an exception so that there is a record of the failure.
if (exceptions.Count > 1)
throw new AggregateException(exceptions);
if (exceptions.Count == 1)
throw exceptions.Single();
}
}
}
How can I change the transport type? Thanks in advance!