Skip to content

Latest commit

 

History

History
59 lines (36 loc) · 2.32 KB

README.md

File metadata and controls

59 lines (36 loc) · 2.32 KB

Azure Blob Storage StacIO

PyPI version CI codecov GitHub License

An implementation of pystac's StacIO for reading static STACs stored in Azure Blob Storage. See the pystac docs for more info.

Installation

Either:

  • pip install az-blob-stacio
  • uv add az-blob-stacio

Usage

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).

Credentials

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 for AZURE_STORAGE_CONNECTION_STRING in 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")