# Create a destination for Microsoft Azure + Fabric or Snowflake

To populate your <u>**Microsoft Azure**</u> repository with healthcare data from an EHR system via Redox (and then to optionally feed that data into <u>**Fabric**</u> or <u>**Snowflake**</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).
- Decide which combination of <u>**cloud products**</u> to use. Redox currently supports any of these combinations with your GCP cloud repository: 
  1. <u>**Microsoft Azure**</u> + <u>**Fabric**</u>


> **OneLake and Fabric**
>
> You can consider Fabric and OneLake interchangeable. The configuration for all three are the same. For simplicity, we refer to Fabric configuration, but use the same instructions if using OneLake.


  2. <u>**Microsoft Azure**</u> + <u>**Snowflake**</u>
- Complete your Azure (and any other cloud product) 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 <u>**Microsoft Entra ID**</u> (formerly Azure Active Directory). [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._

## Configure in Fabric

1. Navigate to the Fabric dashboard and log in.
2. Create a new workspace, or open an existing workspace you want to use for integrating with Redox. 
3. Within the workspace, create a lakehouse, or open an existing lakehouse you want to use for hosting data. 
4. Add **Contributor** permissions for the application you previously created in the Microsoft Azure console.

## 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 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). 
   1. From the <u>Product type</u> field, select **Databricks** or **Snowflake** if you’re using one of those cloud products with Fabric. Your Fabric settings will be ingested with the additional cloud product. 
Select **Fabric** if you’re not also using Databricks or Snowflake. 
2. For the configure destination step, populate these fields. Then click the **Next** button. 
   1. <u>Workspace name</u>: Enter the **name** of the workspace you created in Fabric. 
_Locate this value in the Fabric dashboard._ 
   2. <u>Lakehouse name</u>: Enter the **name** of the lakehouse you created in Fabric. 
_Locate this value in the Fabric workspace configuration._  
   3. <u>File name prefix</u> (optional): Enter any prefix you want prepended to new files when they’re created in the Fabric lakehouse. Add `/` to put the files in a subdirectory. For example, `redox/` puts all the files in the `redox` directory.
3. 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.


4. 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 with these values: 
   - Locate the `clientId` and `clientSecret` value in the Microsoft Azure dashboard. 
   - The `scope` should be the same whether you use Fabric or Snowflake. 


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

```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"
  }

```


3. You should get a successful `200` response and a `payload` populated with the details of the new auth credential. 
4. [Review the Create destination endpoint](https://docs.redoxengine.com/permalink/96830826-bf9c-5d5a-878c-b5b3f1402f30-create-destination).
5. In your terminal, prepare the `/v1/environments/{environmentId}/destinations` request with these values: 
   - 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 workspace and lakehouse setup in the Fabric configuration).  
     - Enter the `productId` based on the additional cloud product you chose:
       - <u>**Fabric**</u>: `fabric` 
       - <u>**Snowflake**</u>: `snowflake`
     - The `fileNamePrefix` is optional, and if added, it gets prepended to the created file path in the Fabric lakehouse. You can also append `/` after the prefix name to indicate a directory path.


**Example: Values for Azure + Fabric or Snowflake cloudProviderSettings**

```json
{
  "cloudProviderSettings": {
    "typeId": "azure",
    "productId": "<fabric_or_snowflake>", 
    "settings": {
      "workspaceName": "<workspace_name_from_Fabric>",
      "lakehouseName": "<lakehouse_name_from_Fabric>",
      "fileNamePrefix": "<optional_file_name_prefix>",
     }
  }
}
```


6. You should get a successful `200` response with a `payload` populated with the details of the new Azure cloud destination. Specifically, the `verified` status of the destination should be set to `true`. 
7. Your new destination will now be able to receive messages. We push data to the lakehouse storage as a JSON file, which is ingested into Microsoft Azure. 
