Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Support for Azure Government Blob Storage #885

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions barman/cloud_providers/azure_blob_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@
except ImportError:
raise SystemExit("Missing required python module: azure-storage-blob")

# Domain for azure blob URIs
# Domains for azure blob URIs
# See https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata#resource-uri-syntax
AZURE_BLOB_STORAGE_DOMAIN = "blob.core.windows.net"
AZURE_GOV_BLOB_STORAGE_DOMAIN = "blob.core.usgovcloudapi.net"


class StreamingBlobIO(RawIOBase):
Expand Down Expand Up @@ -167,10 +168,11 @@ def __init__(
self.max_single_put_size = max_single_put_size

parsed_url = urlparse(url)
if parsed_url.netloc.endswith(AZURE_BLOB_STORAGE_DOMAIN):
if parsed_url.netloc.endswith(AZURE_BLOB_STORAGE_DOMAIN) or parsed_url.netloc.endswith(AZURE_GOV_BLOB_STORAGE_DOMAIN):
# We have an Azure Storage URI so we use the following form:
# <http|https>://<account-name>.<service-name>.core.windows.net/<resource-path>
# where <resource-path> is <container>/<blob>.
# <http|https>://<account-name>.<azure-blob-uri>/<resource-path>
# where <resource-path> is <container>/<blob>
# and <azure-blob-uri> is blob.core.windows.net or blob.core.usgovcloudapi.net.
# Note that although Azure supports an implicit root container, we require
# that the container is always included.
self.account_url = parsed_url.netloc
Expand Down