How can I set config options when using the command-line tools?


robin@...
 

Hi Sean,

That seems to work now - I think I had some problems with how I was setting my environment variables on Windows. Setting them through the GUI configuration dialog (under System->Environment Variables) seems to have worked.

Thanks,

Robin


Sean Gillies
 

Hi Robin,

GDAL config options can always (as far as I know) be set in the program environment. Something like

AZURE_STORAGE_CONNECTION_STRING="SECRET HERE" rio info "az://images-private/SPOT_ROI_COG.tif"

should work.

On Tue, Oct 5, 2021 at 8:17 AM <robin@...> wrote:
Hi,

I'm trying to use the rio command-line tool to access datasets hosted on private Azure Blob Storage.

When using GDAL, a command like this works:

gdalinfo /vsiaz/images-private/SPOT_ROI.tif --config AZURE_STORAGE_CONNECTION_STRING "SECRET HERE"

Or, alternatively, GDAL picks up that config from an environment variable of the same name.

Running:

rio info "az://images-private/SPOT_ROI_COG.tif"

Gives an error saying it can't resolve the host robinanglotest.blob.core.windows.net. I couldn't work out what was going on, as GDAL could obviously resolve the host - but then I tried running Python code where I can set the config option directly:

with rasterio.Env(CPL_CURL_VERBOSE=True, AZURE_STORAGE_CONNECTION_STRING="SECRET"):
    print(img.shape)
    data = img.read()

And it worked fine, with no errors. I assume the command-line tool wasn't picking up the correct config somehow.

How do I go about setting the same AZURE_STORAGE_CONNECTION_STRING config setting so that it works on the command line? There doesn't seem to be an equivalent --config option.

Apologies if this is simple, but I can't seem to find it in the docs and it's been confusing me,

Robin



--
Sean Gillies


robin@...
 

Hi,

I'm trying to use the rio command-line tool to access datasets hosted on private Azure Blob Storage.

When using GDAL, a command like this works:

gdalinfo /vsiaz/images-private/SPOT_ROI.tif --config AZURE_STORAGE_CONNECTION_STRING "SECRET HERE"

Or, alternatively, GDAL picks up that config from an environment variable of the same name.

Running:

rio info "az://images-private/SPOT_ROI_COG.tif"

Gives an error saying it can't resolve the host robinanglotest.blob.core.windows.net. I couldn't work out what was going on, as GDAL could obviously resolve the host - but then I tried running Python code where I can set the config option directly:

with rasterio.Env(CPL_CURL_VERBOSE=True, AZURE_STORAGE_CONNECTION_STRING="SECRET"):
    print(img.shape)
    data = img.read()

And it worked fine, with no errors. I assume the command-line tool wasn't picking up the correct config somehow.

How do I go about setting the same AZURE_STORAGE_CONNECTION_STRING config setting so that it works on the command line? There doesn't seem to be an equivalent --config option.

Apologies if this is simple, but I can't seem to find it in the docs and it's been confusing me,

Robin