# Create a destination for Microsoft Azure + Databricks

To populate your <u>**Microsoft Azure**</u> repository with healthcare data from an EHR system via Redox (and then to feed that data into <u>**Databricks**</u> for analytics), you must configure a specific <u>Redox cloud destination</u>. A Redox <u>destination</u> represents where a message is delivered (e.g., like the address in the “To” line of an email header). [Learn more about connecting Redox to your cloud repository](/basics/connecting-to-the-cloud-with-redox).

You’ll need to perform some steps in your cloud product(s) and some in Redox. You can perform Redox setup in our dashboard or with the Redox Platform API. 

## Prerequisites

- Establish a connection with your preferred EHR system. [Learn how to request a connection](/how-to-use-redox/manage-your-redox-setup/request-a-connection-or-subscription).
- Complete your <u>**Azure**</u> (with <u>**Data Lake**</u>) and <u>**Databricks**</u> configuration _before_ creating your Redox destination. Save any downloads with secret values, since you’ll need to enter some of these details into the Redox dashboard.
- Grant access to Redox from Azure (and any other cloud product) to authorize Redox to push data to your cloud repository.

## Configure in Microsoft Azure

1. Navigate to the Microsoft Azure dashboard and log in. [Review Azure’s quickstart guide](https://learn.microsoft.com/en-us/azure/healthcare-apis/healthcare-apis-quickstart) to get started.
2. Create an **application** through Microsoft Entra ID. [Review Azure’s help article](https://learn.microsoft.com/en-us/azure/healthcare-apis/register-application).
_This is where you_’_ll get a client ID and tenant ID, which you_’_ll need for Redox setup later._
3. Create a new **secret** for your application. 
_This is where you_’_ll get client secret value, which you_’_ll need for Redox setup later._
4. Create a new **storage account**. Set the primary service to the **Data Lake Storage** option.
5. Add a new **container**. 
_You_’_ll need the name of the container for Redox setup later._
6. Assign the appropriate **Blob Data role** (i.e., must at least have <u>**write**</u> permissions) to the application you created in step #2.

## Create a cloud destination in Redox

Next, create a <u>cloud destination</u> in your Redox organization. When the EHR system sends healthcare data to Redox, we push it on to your configured Azure + Databricks cloud destination.

### In the dashboard

1. For the select destination step, [follow the instructions for creating a cloud destination](https://docs.redoxengine.com/permalink/5FMTxkOE7yrDCBgiqfV3Z7/#create-a-destination). 
2. From the <u>Product type</u> field, select **Databricks**. 
3. For the configure destination step, populate these fields. Then click the **Next** button. 
   - <u>Storage account name</u>: Enter the **name** of the storage account you created in Azure. 
_Locate this value in the Azure dashboard._ 
   - <u>Container name</u>: Enter the **name** of the container you created in Azure. 
_Locate this value in the Azure container configuration._  
   - <u>File name prefix</u> (optional): Enter any prefix you want prepended to new files when they’re created in the Data Lake container. Add `/` to put the files in a subdirectory. For example, `redox/` puts all the files in the `redox` directory.
4. For the auth credential step, either a drop-down list of existing auth credentials displays or a new auth credential form opens. [Learn how to create an auth credential](https://docs.redoxengine.com/how-to-use-redox/manage-your-redox-setup/set-up-auth-credentials/#o-auth-2-0-two-legged-with-secrets) for OAuth 2.0 Two-legged. 


> **Token endpoint URL**
>
> To avoid running into validation errors when sending data to your Azure cloud destination, your auth credential should have a `token endpoint URL` that matches this structure:
>
> `https://login.microsoftonline.com/<tenant id from azure console step 2>/oauth2/v2.0/token`

 


> **Existing or new auth credential**
>
> Your existing auth credentials will only display if they’re supported for the cloud product type you selected. If you don’t have any supported auth credentials for the cloud type in the current Redox environment, you’ll have to create a new auth credential.


5. For the verify step, [follow the instructions for verifying a destination](https://docs.redoxengine.com/permalink/5FMTxkOE7yrDCBgiqfV3Z7/#step-4-verify-destination). 

### With the Redox Platform API

1. [Review the Create auth credential endpoint](https://docs.redoxengine.com/permalink/dd0240f7-18d1-593d-87a7-d81bf86f543c-create-auth-cred).
2. In your terminal, prepare the `/v1/authcredentials` request.
3. Specify these values in the request. 
   - Locate the `clientId` and `clientSecret` value in the Microsoft Azure dashboard. 


**Example: Create auth credential for Azure + Databricks**

```json
curl 'https://api.redoxengine.com/platform/v1/authcredentials' \
--request POST \
--header 'Authorization: Bearer $API_TOKEN' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
    "organization": "<Redox_organization_id>"
    "name": "<human_readable_name_for_auth_credential>"
    "environmentId": "<Redox_environment_ID>"
    "authStrategy": "OAuth_2.0_2-legged"
    "url": "https://login.microsoftonline.com/<tenant id from azure console step 1>/oauth2/v2.0/token"
    "grantType": "client_credentials"
    "clientId": "<client_id_from_Azure>"
    "keyId": "<client_secret_from_Azure>"
    "scope": "https://storage.azure.com/.default"
  }

```


4. You should get a successful `200` response and a `payload` populated with the details of the new auth credential. 
5. [Review the Create destination endpoint](https://docs.redoxengine.com/permalink/96830826-bf9c-5d5a-878c-b5b3f1402f30-create-destination).
6. In your terminal, prepare the `/v1/environments/{environmentId}/destinations` request.
7. Specify these values in the request. 
   - Set `authCredential` to the auth credential ID from the response you received in step #4.  
   - Populate `cloudProviderSettings` with the settings below (adjust values based on the storage account and container setup in Azure configuration).  
     - Enter `databricks` as the `productId`.
     - The `fileNamePrefix` is optional. If specified, the filename format will be the prefix you define appended by the file path in the Data Lake container. You can append `/` after the prefix name to indicate a directory path. 


**Example: Values for Azure + Databricks cloudProviderSettings**

```json
{
  "cloudProviderSettings": {
    "typeId": "azure",
    "productId": "databricks", 
    "settings": {
      "storageAccountName": "<storage_account_name_from_Azure>",
      "containerName": "<container_name_from_Azure>",
      "fileNamePrefix": "<optional_file_name_prefix>"
     }
  }
}
```


8. You should get a successful `200` response with a `payload` populated with the details of the new Microsoft Azure + Databricks cloud destination. Specifically, the `verified` status of the destination should be set to `true`. 
9. Your new destination will now be able to receive messages. Redox pushes data to the Data Lake storage account as a JSON file, which is ingested into Microsoft Azure. 
