---
sidebar_position: 1
title: Azure Blob Storage
description: Configure Azure Blob Storage credentials to query files from private containers using MotherDuck.
---

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
import CloudExecutionCallout from "./_cloud-execution-callout.mdx";

## Configure Azure Blob Storage credentials

You can safely store your Azure Blob Storage credentials in MotherDuck for convenience by creating a `SECRET` object using the [CREATE SECRET](/sql-reference/motherduck-sql-reference/create-secret.md) command.

:::note
See [Azure docs](https://learn.microsoft.com/en-gb/azure/storage/common/storage-configure-connection-string#configure-a-connection-string-for-an-azure-storage-account) to find the correct connection string format.
:::

### Create a SECRET object

<Tabs>
<TabItem value="sql" label="SQL">

```sql

-- to configure a secret manually:
CREATE SECRET IN MOTHERDUCK (
    TYPE AZURE,
    CONNECTION_STRING '[your_connection_string]'
);
```


```sql
-- to store a secret configured through `az configure`:
CREATE SECRET az_secret IN MOTHERDUCK (
      TYPE AZURE,
      PROVIDER credential_chain,
      ACCOUNT_NAME 'some-account'
);
```

```sql
-- test the azure credentials
SELECT count(*) FROM 'azure://[container]/[file]'
SELECT * FROM 'azure://[container]/*.csv';
```

</TabItem>

<TabItem value="python" label="Python">

```python

import duckdb

con = duckdb.connect('md:')
con.sql("CREATE SECRET IN MOTHERDUCK (TYPE AZURE, CONNECTION_STRING '[your_connection_string]')");

# testing that our Azure credentials work
con.sql("SELECT count(*) FROM 'azure://[container]/[file]'").show()
con.sql("SELECT * FROM 'azure://[container]/*.csv'").show()
```

</TabItem>

<TabItem value="ui" label="UI">

Click on your profile to access the `Settings` panel and click on `Secrets` menu.

![menu_1](./img/settings_access.png)
![menu_2](./img/settings_panel.png)

Then click on `Add secret` in the secrets section.

![menu_3](./img/settings_secrets_panel.png)

You will then be prompted to enter your Amazon S3 credentials.

![menu_3](./img/secrets_add_azure.png)

</TabItem>
</Tabs>


### Delete a SECRET object

<Tabs>
<TabItem value="sql" label="SQL">

You can use the same method above, using the [DROP SECRET](/sql-reference/motherduck-sql-reference/delete-secret.md) command.

```sql
DROP SECRET <secret_name>;
```

</TabItem>

<TabItem value="ui" label="UI">
Click on your profile and access the `Settings` menu. Click on the bin icon to delete the secret.

![menu_4](./img/secrets_delete_azure.png)

</TabItem>

</Tabs>

### Azure credentials as **temporary** secrets

MotherDuck supports DuckDB syntax for providing Azure credentials.

```sql
CREATE SECRET (
    TYPE AZURE,
    CONNECTION_STRING '[your_connection_string]'
);
```

or if you use the `az configure` command to store your credentials in the `az` CLI.

```sql
CREATE SECRET az_secret (
      TYPE AZURE,
      PROVIDER credential_chain,
      ACCOUNT_NAME 'some-account'
);
```

:::note
Local/In-memory secrets are not persisted across sessions.
:::

<CloudExecutionCallout provider="Azure Blob Storage" />

