My Azure function doesn't trigger when called by my Android app.
Test:
The following test successfully triggers the Azure function via a ServiceBusTrigger:
[<Fact>]
let ``Publish message assigned to servicebus topic``() =
// Setup
let connectionstring = ConfigurationManager.ConnectionStrings.["servicebus_testEnv"].ConnectionString
// Test
async {
let client = TopicClient(connectionstring, "Topic.courier-subscribed")
let data = "test_data"
let message = Message(Encoding.UTF8.GetBytes(data))
do! client.SendAsync(message) |> Async.AwaitTask
do! client.CloseAsync() |> Async.AwaitTask
}
Issue:
However, when I plug the code into my Xamarin Android application, the Azure function never gets triggered.
Instead, I only observe the following error:
System.TimeoutException: 'The operation did not complete within the allocated time 00:00:49.9480520 for object session5.'
Xamarin.Android:
Here's the code in my Xamarin Android app:
let subscribe : Subscribe =
fun request ->
async {
let body = {
Courier = request.Courier
Location = request.Location
Timestamp = DateTime.Now
}
try
let connectionstring = QueueTopic.Instance.ConnectionString
let client = TopicClient(connectionstring, "Topic.courier-subscribed")
let json = JsonConvert.SerializeObject(body)
let message = Message(Encoding.UTF8.GetBytes(json))
do! client.SendAsync(message) |> Async.AwaitTask
do! client.CloseAsync() |> Async.AwaitTask
return Ok body
}
Azure Function (ServiceBusTrigger):
public static class SubscribedFn
{
[FunctionName(nameof(SubscribedFn))]
public static async Task Run([ServiceBusTrigger("Topic.courier-subscribed", "Subscription.all-messages", Connection= "ServiceBusConnectionKey")]
string json, ILogger log)
{
... // NEVER INVOKED
}
NOTE:
I have verified the connection string to be identical with my automated test.
The automated test triggers the Azure function via ServiceBusTrigger every time.
I have verified that I'm sending JSON as the payload in both clients