# Azure Service Bus

{% hint style="info" %}
The following documentation is for **Azure Service Bus v1.3.4** *(BDK)*.
{% endhint %}

## Overview

Azure Service Bus provides reliable cloud messaging as a service (MaaS) and simple hybrid integration. This integration enables automated message queuing, publish-subscribe messaging, and enterprise messaging workflows. Enhance application reliability and enable scalable communication between distributed applications and services.

## Prerequisites

### 1. Required Books

The following Book(s) need to be added to your agent so it can learn and understand the automation procedures defined within them:

* **Azure Service Bus**

#### How to Add the Book(s)

1. Go to **Books** → **All Books**.
2. Search for the name of the book and click on it.
3. Click on <kbd>**Install**</kbd> or <kbd>**Add Connection**</kbd> to add the book to your agent.
4. If adding a connection, you'll be prompted for [**connectivity**](#connectivity) details.

## Connectivity

This section outlines the available methods for connecting to the Book, along with the required configuration details for each.

### Connect using Connection String

Connect to Azure Service Bus using connection string parameters.

| Label             | Description                                         | Type        |
| ----------------- | --------------------------------------------------- | ----------- |
| Connection String | The connection string for the Service Bus namespace | `sensitive` |

## Procedures

### to receive a (message) from a queue

Get the latest message from an Azure Service Bus queue.

**Input Concepts**

| Concept         | Description                                   | Type     | Required | Default Value |
| --------------- | --------------------------------------------- | -------- | -------- | ------------- |
| `queue name`    | The name of the Azure Service Bus queue       | `text`   | Yes      | (no default)  |
| `max wait time` | Maximum time to wait for a message in seconds | `number` | No       | (no default)  |

**Output Concepts**

| Concept   | Description                                | Type   |
| --------- | ------------------------------------------ | ------ |
| `message` | The latest message received from the queue | `text` |

**Examples**

Receive a message from Azure Service Bus queue

```generic
receive a message from a queue with
    the queue name is "myqueue"
```

Receive a message from Azure Service Bus queue with a maximum wait time of 60 seconds

```generic
receive a message from a queue with
    the queue name is "myqueue"
    the max wait time is 60
```

### to send a message to a queue

Send a message to an Azure Service Bus queue.

**Input Concepts**

| Concept      | Description                             | Type   | Required | Default Value |
| ------------ | --------------------------------------- | ------ | -------- | ------------- |
| `message`    | The message to be sent                  | `text` | Yes      | (no default)  |
| `queue name` | The name of the Azure Service Bus queue | `text` | Yes      | (no default)  |

**Examples**

Send a message to an Azure Service Bus queue

```generic
send "Hello, World!" to a queue with
    the queue name is "myqueue"
```
