# Trying to get stations into Inventory using Client but failing in Linux Azure Function

**URL:** <https://discourse.obspy.org/t/trying-to-get-stations-into-inventory-using-client-but-failing-in-linux-azure-function/1117>\
**Category:** Usage Questions\
**Created:** [November 5, 2020, 3:38am UTC](https://discourse.obspy.org/t/trying-to-get-stations-into-inventory-using-client-but-failing-in-linux-azure-function/1117 "2020-11-05T03:38:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hooan](https://discourse.obspy.org/user_avatar/discourse.obspy.org/hooan/32/352_2.png) [@hooan](https://discourse.obspy.org/u/hooan)\
**Post date:** [November 5, 2020, 3:38am UTC](https://discourse.obspy.org/t/trying-to-get-stations-into-inventory-using-client-but-failing-in-linux-azure-function/1117/1 "2020-11-05T03:38:55Z")

</div>

Hi All,

I am creating an FDSN client to use the get\_stations function to get the stations.

To do this, I am calling get\_stations as follows:

```
        inventory = client.get_stations(latitude = latitude , longitude = longitude,
                                                maxradius = maxradius , starttime = starttime,
                                                endtime = endtime, location ="2*", channel="H*", level="response")

```

This runs fine locally and on windows. After deploying it to a Python Azure Function running on Linux, I am getting the following error:

```
 in get_relevant_stations inventory = client.get_stations(latitude = site_latitude,
 longitude = site_longitude,
 File "/home/site/wwwroot/.python_packages/lib/site-packages/obspy/clients/fdsn/client.py",
 line 732,
 in get_stations inventory = read_inventory(data_stream) File "<decorator-gen-49>",
 line 2,
 in read_inventory File "/home/site/wwwroot/.python_packages/lib/site-packages/obspy/core/util/decorator.py",
 line 300,
 in _map_example_filename return func(*args,
 **kwargs) File "/home/site/wwwroot/.python_packages/lib/site-packages/obspy/core/inventory/inventory.py",
 line 88,
 in read_inventory return _generic_reader(path_or_file_object,
 _read,
 format=format,
 File "/home/site/wwwroot/.python_packages/lib/site-packages/obspy/core/util/base.py",
 line 677,
 in _generic_reader generic = callback_func(fh.name,
 **kwargs) File "<decorator-gen-50>",
 line 2,
 in _read File "/home/site/wwwroot/.python_packages/lib/site-packages/obspy/core/util/decorator.py",
 line 210,
 in uncompress_file result = func(filename,
 *args,
 **kwargs) File "/home/site/wwwroot/.python_packages/lib/site-packages/obspy/core/inventory/inventory.py",
 line 97,
 in _read inventory,
 format = _read_from_plugin('inventory',
 filename,
 format=format,
 File "/home/site/wwwroot/.python_packages/lib/site-packages/obspy/core/util/base.py",
 line 450,
 in _read_from_plugin raise TypeError('Unknown format for file %s' % filename)Result: Failure Exception: TypeError: Unknown format for file /tmp/obspy-0yop00ed.tmp 

```

How can I make sure that get\_stations works in my Python Azure function running on Linux? I’ve tried saving the API response in a file by specifying a filename and type. I can save this file successfully. I can also read this file manually using Python, but using ObsPy’s read\_inventory function still raises the error. It’s really weird since it works properly on my local windows environment.

---

<div class="post-metadata">

**Author:** ![megies](https://discourse.obspy.org/user_avatar/discourse.obspy.org/megies/32/9_2.png) [@megies](https://discourse.obspy.org/u/megies)\
**Post date:** [November 12, 2020, 12:36pm UTC](https://discourse.obspy.org/t/trying-to-get-stations-into-inventory-using-client-but-failing-in-linux-azure-function/1117/2 "2020-11-12T12:36:21Z")

</div>

> [@hooan](#):
>
> I can also read this file manually using Python, but using ObsPy’s read\_inventory function still raises the error.

You’ll have to clarify. You can “read the file manually”, but you can not read with Obspy? What is “manual”? The error message indicates a broken file as most likely cause, anyway. Seems like it goes through our file format detection and none of our `_is_format_xxx()` routines can recognize it.

---

<div class="post-metadata">

**Author:** ![megies](https://discourse.obspy.org/user_avatar/discourse.obspy.org/megies/32/9_2.png) [@megies](https://discourse.obspy.org/u/megies)\
**Post date:** [November 13, 2020, 9:04am UTC](https://discourse.obspy.org/t/trying-to-get-stations-into-inventory-using-client-but-failing-in-linux-azure-function/1117/3 "2020-11-13T09:04:30Z")

</div>

Cross posted on github: [Possible bug with using Linux Azure Functions and get\_stations not working · Issue #2745 · obspy/obspy · GitHub](https://github.com/obspy/obspy/issues/2745)

---

<div class="post-metadata">

**Author:** ![hooan](https://discourse.obspy.org/user_avatar/discourse.obspy.org/hooan/32/352_2.png) [@hooan](https://discourse.obspy.org/u/hooan)\
**Post date:** [November 15, 2020, 8:17pm UTC](https://discourse.obspy.org/t/trying-to-get-stations-into-inventory-using-client-but-failing-in-linux-azure-function/1117/4 "2020-11-15T20:17:32Z")

</div>

get\_stations can either save the inventory into an object, but if you specify a filename, it can save it into a file.

I was able to save it into a file and read it using `open('workfile', 'w')`. This worked both locally and on Azure Functions running Python. Reading this locally using ObsPy’s `read_inventory` function works but not when deployed on Azure Functions for Python.

Eventually, I tried different Setups for Azure Functions Environments. I was running it on a consumption plan which is where I was experiencing all those issues. Running it on the Dedicated (App Service) B3 tier Plan worked and I was able to get the same output I was getting locally. There might some limitations for Azure Functions running on a consumption plan. I’m currently trying different setups and it seems like running it on a dedicated plan is a fix.
