An implementation of pystac's StacIO for reading static STACs stored in Azure Blob Storage. See the pystac docs for more info.
Either:
pip install az-blob-staciouv add az-blob-stacio
Set the global default StacIO to BlobStacIO:
import os
from az_blob_stacio import BlobStacIO
BlobStacIO.conn_str = os.environ["AZURE_STORAGE_CONNECTION_STRING"]
pystac.StacIO.set_default(BlobStacIO)
catalog = pystac.Catalog.from_file("https://myaccount.blob.core.windows.net/mycontainer/catalog.json")Or use a context manager to temporarily set BlobStacIO as the default StacIO and reset to DefaultStacIO upon exiting the context:
import os
from az_blob_stacio import BlobStacIO, custom_stacio
BlobStacIO.conn_str = os.environ["AZURE_STORAGE_CONNECTION_STRING"]
with custom_stacio(BlobStacIO):
catalog = pystac.Catalog.from_file("https://myaccount.blob.core.windows.net/mycontainer/catalog.json")Overwrite behavior is configurable by setting BlobStacIO.overwrite (defaults to True).
Azure Blob Storage credentials can be provided by setting either of the following class variables:
-
BlobStacIO.conn_str: a connection string for the Azure storage account. Checks forAZURE_STORAGE_CONNECTION_STRINGin your environment by default. -
BlobStacIO.credential: a credential that provides access to the storage account hosting the static STAC.from azure.core.credentials import AzureSasCredential BlobStacIO.credential = AzureSasCredential("my-sas-token")