> For the complete documentation index, see [llms.txt](https://docs.jugalbandi.opennyai.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jugalbandi.opennyai.org/building-with-jugalbandi/technical-guide/references/storage.md).

# Azure Storage

***

JB Manager leverages [Azure Blob Storage](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction) for the persistent storage of input and output files through which user interacts with the bot. Alternatively, we have the flexibility of switching to a local storage as well.

In this document, we have covered the below-mentioned aspects for utilizing either of the storages effectively:

* Introduction
  * Preferred Scenario
  * Prerequisites
* Step-by-step Configuration

## Introduction

### Azure Blob Storage

* **Preferred Scenario**:
  * **Scalability Needs**: When you need to scale storage capacity quickly and efficiently without worrying about hardware limitations
  * **High Availability and Durability**: When you require high availability and durability with data redundancy across multiple locations
  * **Managed Services**: When you want to offload hardware maintenance, updates, and critical issue management to a cloud provider
* **Prerequisites**:
  * **Azure Storage Account**: First, you will need to setup an Azure Storage Account on the portal (refer the [link](https://learn.microsoft.com/en-us/azure/storage/common/storage-account-create?tabs=azure-portal))
  * **Containers**: Next, you will create a container which will be used to store the files

### Local Storage

* **Preferred Scenario**:
  * **High-Speed Access Required**: When applications require very low latency and high-speed access to data
  * **Complete Data Control**: When you need full control over data storage, management, and security (highly confidential files)
* **Prerequisites**:
  * **Hardware Requirements**: Ensure you have sufficient hardware resources, such as hard drives (HDDs) or solid-state drives (SSDs), to meet your storage needs
  * **Backup and Redundancy**: Implement robust backup and redundancy strategies to protect against data loss due to hardware failures or other issues

## Configuration

### Setting up Environment Variables

* To use **Azure Blob Storage**, you need to update the following lines in `.env-dev`:

  ```
     STORAGE_TYPE=azure
     AZURE_STORAGE_ACCOUNT_URL=<your_storage_account_url>
     AZURE_STORAGE_ACCOUNT_KEY=<your_storage_account_key>
     AZURE_STORAGE_CONTAINER=<your_container_name>
  ```
* To use **Local Storage**, you need to update the following lines in `.env-dev`:

  ```
    STORAGE_TYPE=local
    PUBLIC_URL_PREFIX=<tunnerl_url>
  ```
* By default, the JB Manager utilizes **Local Storage** unless specified using the above pointers

### FAQs:

* What is the significance of `PUBLIC_URL_PREFIX`?
  * To refer and access the inputted files across services in the JB Manager i.e. `Language` service in case of audio files
* What are the default storage paths in both cases?
  * In case of Azure Blob Storage, default location is `/tmp/jb_files` within the defined container
  * While, in case of local storage, default location is `/mnt/jb_files`
* I am already utilizing the `tmp` folder in the Azure Blob storage container in a different process. So is there a way to change the default path?

  * Yes, you could define the custom path in `azure_storage.py` at `jb-lib/lib/file_storage/azure` in case of Azure option

  ```
      class AzureAsyncStorage(AsyncStorage):
         __client__ = None
         tmp_folder = "/tmp/jb_files" # Update the path here
  ```

  * While in case of local storage, update the `local_storage.py` at `jb-lib/lib/file_storage/local/`

  ```
     class LocalAsyncStorage(AsyncStorage):
        tmp_folder = "/mnt/jb_files" # Update the path here
  ```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.jugalbandi.opennyai.org/building-with-jugalbandi/technical-guide/references/storage.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
