# Manually Run a Non-HTTP Triggered Azure Function

# Introduction

Sometimes, we need to trigger our Azure Functions indirectly. What that means is that we want to trigger a function that is on a schedule or a function that runs as a result of an action from another resource. That action can be from a Blob storage, Service Bus Queue or Topic and other.

In this example, we will take a look at how we can manually run an Azure function that responds to messages from a Service Bus queue.

We will learn how to trigger the function without actually sending a message to the queue.

---

# Examining the Azure function

For this example, we have a very simple Azure function. The code for the function implementation is the following:

```csharp
namespace FunctionAppSbTrigger
{
    public class Function1
    {
        [FunctionName("MyAwesomeFunction")]
        public void Run([ServiceBusTrigger("myqueue", Connection = "ServiceBusConnection")]string myQueueItem, ILogger log)
        {
            log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
        }
    }
}
```

We can see that we have the Service Bus trigger set up that responds to messages from the "myqueue" queue.

Now if we try sending a message to the queue, we can observe that our function executes successfully.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762858245558/0b6895f3-b441-4ed9-a994-78b6ed547e0f.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762858230480/fbec269f-bcb4-4884-8170-effcc6e49397.png align="center")

But what if we have a situation where we don't want to or just simply can't send a message to the queue. How can we test our function then?

---

# Manually running the function

To run a non HTTP-triggered function, we can send a simple `HTTP POST` request.

Now you might be thinking "But Dimitar, this is not even an HTTP triggered function, how can we do that?" and you're right.

We will need to construct a special type of URL to make this request to.

The code of our `launchSettings.json` file is:

```json
{
  "profiles": {
    "FunctionAppSbTrigger": {
      "commandName": "Project",
      "commandLineArgs": "--port 7289",
      "launchBrowser": false
    }
  }
}
```

We will construct the new URL using the following information:

* **Host name:** The function app's public location
    
* **Folder path:** we have to send the request through the folders *admin/functions*
    
* **Function name:** name of the function we want to run
    

The special URL will have the form:

```yaml
{hostName}/{folderPath}/{functionName}
```

Replacing these values gives us the final state of the URL:

```yaml
http://localhost:7289/admin/functions/MyAwesomeFunction
```

---

# Testing it all out

Next, let's open Postman and do a simple test.

We will set the HTTP method to `POST` and use the `URL` from the previous step. We can also specify a body for our request.

> if we don't want to pass any data to our function, we still need to pass {} as the body of the request.

In the `Headers` section set the `'Content-Type'` to `'application/json'`.

You should have a similar setup as the image below:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762858455404/b8cad63f-f1d2-4047-963d-eae5465eeb8e.png align="center")

Now click on the 'Send' button. Observe that we have successfully triggered our Azure Function without sending any messages to the queue.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762858479958/34d4df3c-d067-45c7-8ff7-8699233e844e.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762858493279/bb7da855-bd26-4f71-9664-1123caace1dd.png align="center")

---
