# Is there elsewhere to put the .cdsapirc file? Running it on Databricks

**URL:** <https://forum.ecmwf.int/t/is-there-elsewhere-to-put-the-cdsapirc-file-running-it-on-databricks/956>\
**Category:** API\
**Tags:** api, c3s\
**Created:** [14 August 2023 10:19 UTC](https://forum.ecmwf.int/t/is-there-elsewhere-to-put-the-cdsapirc-file-running-it-on-databricks/956 "2023-08-14T10:19:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![HANPU\_YAO](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/h/ebca7d/32.png) [@HANPU\_YAO](https://forum.ecmwf.int/u/HANPU_YAO)\
**Post date:** [14 August 2023 10:19 UTC](https://forum.ecmwf.int/t/is-there-elsewhere-to-put-the-cdsapirc-file-running-it-on-databricks/956/1 "2023-08-14T10:19:12Z")

</div>

Hi everyone, I am trying to extract ERA5 data on Databricks. It turns out that the home path (home/) is not available in Databricks because I don't have access right to it. So, is there any way that I can manage to use my cdsapi and extract data in Databricks?

---

<div class="post-metadata">

**Author:** ![Laurens\_Stoop](https://forum.ecmwf.int/user_avatar/forum.ecmwf.int/laurens_stoop/32/480_2.png) [@Laurens\_Stoop](https://forum.ecmwf.int/u/Laurens_Stoop)\
**Post date:** [13 May 2024 15:27 UTC](https://forum.ecmwf.int/t/is-there-elsewhere-to-put-the-cdsapirc-file-running-it-on-databricks/956/2 "2024-05-13T15:27:53Z")

</div>

For who finds this, a sollution I found for databricks:

```auto
import os

# Set the API credentials as environment variables
os.environ['CDSAPI_URL'] = 'https://cds.climate.copernicus.eu/api/v2'
os.environ['CDSAPI_KEY'] = 'your_api_key_here'

```

Make sure to use the correct API key you find on [How to use the CDS API | Copernicus Climate Data Store](https://cds.climate.copernicus.eu/api-how-to)

---

<div class="post-metadata">

**Author:** ![Matteo\_De\_Felice12](https://forum.ecmwf.int/user_avatar/forum.ecmwf.int/matteo_de_felice12/32/413_2.png) [@Matteo\_De\_Felice12](https://forum.ecmwf.int/u/Matteo_De_Felice12)\
**Post date:** [15 May 2024 09:30 UTC](https://forum.ecmwf.int/t/is-there-elsewhere-to-put-the-cdsapirc-file-running-it-on-databricks/956/3 "2024-05-15T09:30:20Z")

</div>

FYI, this is the setup we use on our Azure Databricks:

```auto
url = 'url: https://cds.climate.copernicus.eu/api/v2'
key = 'key: your_api_key_here'

with open('/root/.cdsapirc', 'w') as f:
    f.write('\n'.join([url, key]))

```

---

<div class="post-metadata">

**Author:** ![Laurens\_Stoop](https://forum.ecmwf.int/user_avatar/forum.ecmwf.int/laurens_stoop/32/480_2.png) [@Laurens\_Stoop](https://forum.ecmwf.int/u/Laurens_Stoop)\
**Post date:** [23 July 2024 11:53 UTC](https://forum.ecmwf.int/t/is-there-elsewhere-to-put-the-cdsapirc-file-running-it-on-databricks/956/4 "2024-07-23T11:53:17Z")

</div>

Or even better by using the ‘dbutils.secrets’ functionality of Databrics like (as instructed by a dev within my team):

```auto
 # Set the API credentials as environment variables (NEATER)
os.environ['CDSAPI_URL'] = 'https://cds.climate.copernicus.eu/api/v2'
os.environ['CDSAPI_KEY'] = dbutils.secrets.get(scope = "keyvault_secretscope_name", key = "Copernicus-api-key")

```

@HANPU_YAO & @Matteo_De_Felice12 the downside of earlier methods is the ‘publication’ of your key.

---

<div class="post-metadata">

**Author:** ![Koen\_Hufkens](https://forum.ecmwf.int/user_avatar/forum.ecmwf.int/koen_hufkens/32/526_2.png) [@Koen\_Hufkens](https://forum.ecmwf.int/u/Koen_Hufkens)\
**Post date:** [28 August 2024 09:46 UTC](https://forum.ecmwf.int/t/is-there-elsewhere-to-put-the-cdsapirc-file-running-it-on-databricks/956/5 "2024-08-28T09:46:13Z")

</div>

+1 , and should be implemented in the python library by default IMO.
