# Azure Integration

**Azure Storage:** [Azure Storage Documentation Link](https://learn.microsoft.com/en-us/azure/storage/)

---

**🛑 General restrictions**: Azure Storage is not a traditional file system but an object storage service. What appears to be a **folder** is actually just a prefix in the object’s name. As a result, renaming folders is not supported. To **move** a folder, you must copy all the objects to the new location and then delete them from the original one.

---

**🛑 Proxy Configuration:** If your server accesses the internet through a proxy, make sure to whitelist the following domains to allow Azure API access:\
• **file.core.windows.net** or **privatelink.file.core.windows.net**\
• **blob.core.windows.net**, **blob.core.chinacloudapi.cn** or **privatelink.blob.core.windows.net**\
• **dfs.core.windows.net**,**dfs.core.chinacloudapi.cn** (This applies only to the delete action when working with Data Lake Storage 2)

---

#### 1. Azure File Share

CrushFTP supports Microsoft Azure Shares as a [VFS](VFS.md) item, it requires a **Storage Account:** [Storage account overview Link](https://learn.microsoft.com/en-us/azure/storage/common/storage-account-overview).\
More Info: [Azure File Share Link](https://learn.microsoft.com/en-us/azure/storage/files/storage-how-to-create-file-share?tabs=azure-portal)

The URL should follow this structure (replace the placeholders with your actual values):

```

azure://<<STORAGE_ACCOUNT_NAME>>:<<ACCESSKEY>>@file.core.windows.net/<<SHARE_NAME>>/
or
azure://<<STORAGE_ACCOUNT_NAME>>:<<ACCESSKEY>>@privatelink.file.core.windows.net/<<SHARE_NAME>>/
```

You can find the required details in the **Azure Portal**. Navigate to your **Storage Account**, then select **Access keys** from the left-hand menu to view the credentials.

![Azure Portal Access Key](Azure-Integration/AzurePortalAccessKey.png)

In the VFS item’s Properties section, provide the **Storage Account** name as the **Username** and the **Access key** as the **Password**. The **Share Name** corresponds to the first folder in the URL.

![Azure Configuration 3](Azure-Integration/AzureConfiguration3.png)

When using the **Browse…** option in the Jobs interface or plugin interfaces, the user interface differs slightly:

There is an input field specifically for the file service share, labeled **Share Name**.\
![Azure Remote Item 3](Azure-Integration/azureRemoteItem3.png)

#### 2. Azure Blob Container

CrushFTP supports **Azure Blobs** ([Introduction to Azure Blob Storage Link](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction)) as VFS item, it requires a **Storage Account:** [Storage account overview Link](https://learn.microsoft.com/en-us/azure/storage/common/storage-account-overview).

The URL should follow this structure (replace the placeholders with your actual values):

```

azure://<<STORAGE_ACCOUNT_NAME>>:<<ACCESSKEY>>@blob.core.windows.net/<<BLOB_CONTAINER_NAME>>/
or
azure://<<STORAGE_ACCOUNT_NAME>>:<<ACCESSKEY>>@blob.core.chinacloudapi.cn/<<BLOB_CONTAINER_NAME>>/
or
azure://<<STORAGE_ACCOUNT_NAME>>:<<ACCESSKEY>>@privatelink.blob.core.windows.net/<<BLOB_CONTAINER_NAME>>/
```

In the VFS item’s Properties section, provide the **Storage Account** name as the **Username** and the **Access key** as the **Password**. The **Blob Container Name** corresponds to the first folder in the URL.

**⚠️ Important** : You need to select the appropriate blob type—**Append Blob** or **Block Blob**—as specified when the blob was created in Azure. Page Blobs are not supported.

![Azure blob 3](Azure-Integration/azure_blob3.png)

**Data Lake storage Gen2**: More info on the official website: [Data Lake Storage Introduction Link](https://learn.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-introduction).\
Turn on the flag if the storage type is the data lake. It connects using the **Azure Blob Storage REST API** ( More info: [Blob Service REST API Link](https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api)), but does not support the Azure Data Lake Storage Gen2 REST API. (More info: [Azure Data Lake Storage Gen2 REST API Link](https://learn.microsoft.com/en-us/rest/api/storageservices/data-lake-storage-gen2))

When using the **Browse…** option in the Jobs interface or plugin interfaces, the user interface differs slightly:

To specify the **Blob Container Name**, use the **Share Name** input field.

![Azure blob Remote Item](Azure-Integration/azure_blobRemoteItem.png)

#### 3. SAS token

Azure also can delegate access with a shared access signature (SAS) [Storage SAS Overview Link](https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview).\
In this case, the URL should look like:

```

azure://<<STORAGE_ACCOUNT_NAME>>:@blob.core.windows.net/<<BLOB_CONTAINER_NAME>>/
or
azure://<<STORAGE_ACCOUNT_NAME>>:@file.core.windows.net/<<SHARE_NAME>>/
```

**⚠️ Note:** that the URL does not include the password section.

![SAS](Azure-Integration/SAS.png)

Provide the Storage Account name as the Username.\
The **Password** field should be left empty, and the **SAS token** should be entered in the **Shared access signature token** input field.

The **Share Name** or **Blob Container Name** corresponds to the first folder in the URL.

**Block Blob**: **⚠️ Important** -> You need to select the appropriate blob type—**Append Blob** or **Block Blob**—as specified when the blob was created in Azure. Page Blobs are not supported.

![Azure VFS SAS](Azure-Integration/azure_VFS_SAS.png)

When using the Browse… option in the Jobs interface or plugin interfaces, the user interface differs slightly. See at [1.Azure File Share Link](Azure-Integration.md#section-Azure+Integration-1.AzureFileShare) or at [2. Azure Blob Container Link](Azure-Integration.md#section-Azure+Integration-2.AzureBlobContainer).

#### 4. Authorize access to Azure Storage using Microsoft Entra ID

Azure Storage supports using Microsoft Entra ID to authorize requests to blob data. (More info : [Authorize Access Azure Active Directory Link](https://learn.microsoft.com/en-us/azure/storage/blobs/authorize-access-azure-active-directory))

**⚠️ Proxy Configuration:** If your server accesses the internet through a proxy, make sure to whitelist the following domains to allow authentication and Microsoft Graph API access:\
• login.microsoftonline.com\
• graph.microsoft.com

Open the **Microsoft Azure Portal**: [Link](https://azure.microsoft.com/en-us/features/azure-portal)

**Application registration:** Navigate to App registrations in the Azure Portal. Click on **New registration** to create a new application.

![New registration](SharePoint-Integration/new_registration.png)

In the Redirect URI section, for Platform configuration, select **Web**. The Redirect URL must end with **register_microsoft_graph_api/**.

```

    http://localhost:9090/register_microsoft_graph_api/
    or
    https://your.crushftp.domain.com/register_microsoft_graph_api/
    
```

**Secret key**: A new client secret must be created. Go to Certificates & secrets, and generate a new client secret by clicking on New client secret. ⚠️ Ensure you copy over the **value** immediately!

![New secret](SharePoint-Integration/new_secret.png)

![Secret value](SharePoint-Integration/secret_value.png)

Configure the **API permissions**:

![Azure api permission blob](Azure-Integration/azure_api_permission_blob.png)

![Azure user impersonation](Azure-Integration/azure_user_impersonation.png)

In your **Storage Account**, navigate to **Access Control (IAM)** and assign the roles **Storage Account Contributor** and **Storage Blob Data Contributor** to the specified user.

**⚠️ Important**: This applies only to **Blob Storage**.

![Azure access control roles](Azure-Integration/azure_access_control_roles.png)

Access the user’s **VFS settings** and configure the **Refresh Token** for the remote Azure connection.\
• Provide the **Storage Account Name** in the **Username** input field.\
• Under **User Delegation Settings**, click the **Get Refresh Token** button.

![User delegation settings](Azure-Integration/user_delegation_settings.png)

**⚠️ Important**: To obtain the **Refresh Token**, the CrushFTP WebInterface’s host and port must match the **Redirect URL** specified in the **Azure App Registration**. In our example, it was: http<!-- -->://localhost:9090 or https<!-- -->://your.crushftp.domain.com/

**Client id :** See at App Registration -> Overview -> Application (client) ID

**Secret key:** See at App Registration -> Manage -> Certificates & secrets) make sure to copy the **value** field, not the ID.

**Tenant:** See at App Registration -> Overview -> Directory (tenant) ID.

**Scope:**

```
    https://storage.azure.com/user_impersonation offline_access
```

Click OK. Sign in with the specified Microsoft account to grant access and obtain the refresh token. **⚠️ Note**: Be sure to sign in with the Microsoft Account that has the necessary permissions, as configured in the Azure App Registration mentioned above. This will automatically configure the **User Delegation Settings**.\
![Azure refresh token form](Azure-Integration/azure_refresh_token_form.png)

**Version 11.4.1_8+**: The User Delegation Settings allow for OAuth2 authentication with Azure Storage. Utilizing this delegation method replaces the previous requirement for generating temporary SAS tokens.\
**⚠️ Outdated**: To generate a new SAS token for your storage account, run the following job example: [Renew Azure SAS token via Azure User impersonation](CrushTaskExample18.md)
