# Connecting to an Azure Blob Container

## 1. Create the Azure Application

Start by creating an application registration in Azure **without assigning any permissions yet**.

---

## 2. Assign Roles from the Container

From your Azure Blob container, go to **Access Control (IAM)** and click:

:::note

## `Add role assignment`

:::

   <div class="docs-screenshot-compact">

   ![Add role assignment](./assets/add-role-assignment.png)

   </div>

### Recommended Roles

| Role Name                         | Description                                                 |
| --------------------------------- | ----------------------------------------------------------- |
| **Reader**                        | Read-only access.                                           |
| **Storage Blob Data Contributor** | Read, write, and delete access to blob containers and data. |

---

## 3. Configure the Credential in Mindflow

Set up an **OAuth 2.0 (Client Credentials)** credential in Mindflow.

   <div class="docs-screenshot-compact">

   ![3 configure credential mindflow](./assets/3-configure-credential-mindflow.png)

   </div>

💡 **Important**:

Ensure that **Client Authentication** is set to: **`Embed client credential in Request Body`**

**Resource (scope)** to use: `https://storage.azure.com`

---

## 4. Available API Calls

:::note
This action is currently not natively supported in Mindflow. Use an HTTP Request module instead.
:::

### 📤 PUT Blob (Upload or Update a Blob)

📚 [Official Microsoft documentation](https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob?tabs=microsoft-entra-id)

   <div class="docs-screenshot-compact">

   ![Put blob upload update blob](./assets/put-blob-upload-update-blob.png)

   </div>

### Required Headers

| Header           | Description                                                      |
| ---------------- | ---------------------------------------------------------------- |
| `x-ms-version`   | API version. Default: **2020-10-02**                             |
| `x-ms-date`      | Request timestamp (format detailed below)                        |
| `Content-Type`   | MIME type of the document being uploaded                         |
| `x-ms-blob-type` | Type of blob to create: `BlockBlob`, `PageBlob`, or `AppendBlob` |

   <div class="docs-screenshot-compact">

   ![Required headers](./assets/required-headers.png)

   </div>

💡 **Required format for `x-ms-date`:** `EEE, dd MMM yyyy HH:mm:ss 'GMT'`

## (e.g., Mon, 30 Jun 2025 14:00:00 GMT)

🔸 **Body**: Contains the file content to upload.

### 📥 GET Blob (Download a Blob)

📚 [Official Microsoft documentation](https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob?tabs=microsoft-entra-id)

   <div class="docs-screenshot-compact">

   ![Get blob download blob](./assets/get-blob-download-blob.png)

   </div>

### Required Header

| Header         | Description             |
| -------------- | ----------------------- |
| `x-ms-version` | Default: **2020-10-02** |
