NAME
Azure::SDK::Storage::Blobs::ConnectionString - parse an Azure Storage blob connection string
SYNOPSIS
use Azure::SDK::Storage::Blobs::ConnectionString;
my $connection = Azure::SDK::Storage::Blobs::ConnectionString->parse(
$ENV{BLOBS_CONNECTIONSTRING} // $ENV{ConnectionStrings__blobs}
);
$connection->blob_endpoint; # http://127.0.0.1:58354/devstoreaccount1
$connection->endpoint_path; # /devstoreaccount1
$connection->account_name; # devstoreaccount1
$connection->credential; # Azure::SDK::Core::Credential::SharedKey
DESCRIPTION
Parses and validates an Azure Storage blob connection string. Two shapes are supported.
The account form the Azure portal emits, where the endpoint is derived:
DefaultEndpointsProtocol=https;AccountName=<name>;AccountKey=<base64>
The explicit-endpoint form, used when the endpoint cannot be derived from the account name -- a local emulator on an arbitrary port, or a custom domain:
DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=<base64>;BlobEndpoint=http://127.0.0.1:58354/devstoreaccount1;
Alternatively SharedAccessSignature accepts a precomputed SAS instead of AccountKey. Supply BlobEndpoint or AccountName to derive the standard endpoint; do not combine the key and SAS. Field names are matched case-insensitively, unrecognized fields are ignored, and a trailing ; is tolerated.
Endpoint derivation
When BlobEndpoint is absent, the endpoint is built as {protocol}://{account}.blob.{suffix}. EndpointSuffix selects a sovereign cloud and defaults to core.windows.net; DefaultEndpointsProtocol selects the scheme and defaults to https. An explicit BlobEndpoint always wins, which is what makes emulators and custom domains work.
EndpointSuffix is held to a bare DNS suffix of at most 253 characters. It becomes part of a hostname that requests are signed against, so a value carrying a scheme, userinfo, port, path, or query is rejected rather than spliced into the endpoint.
Parsing is deliberately strict, because the parsed values are used to build URLs and to sign requests:
A repeated field name is rejected rather than silently resolved, so a merged or tampered configuration value cannot quietly change the endpoint or key.
UseDevelopmentStorage=trueis rejected. The shorthand implies an emulator on the fixed port 10000, which a container-hosted emulator will not necessarily be published on. SupplyBlobEndpointinstead.BlobEndpoint, when supplied, must be an absolutehttp/httpsURI with a host and without userinfo, query, fragment, or relative path segments. The same rules are applied by Azure::SDK::Storage::Blobs::Uri, so an endpoint faces one set of checks however it was configured.AccountNamemust be 3-24 alphanumeric characters, which keeps separators and control characters out of theAuthorizationheader and the canonicalized resource.AccountKeyis shape-checked as base64 and immediately wrapped in an Azure::SDK::Core::SecretString. Neither the validation errors norto_stringever include the key.The 8 KiB input cap is measured in bytes, not characters, so a decoded value cannot exceed the documented bound while appearing to fit inside it.
Endpoint path
endpoint_path is the path component of blob_endpoint, normalized without a trailing slash. Emulators such as Azurite place the account name in the URL path (/devstoreaccount1) rather than in the host. Shared-key canonicalization is defined over the full request URI path, so the signer must prepend this path to the container and blob segments. Against real Azure Storage the account is part of the host and endpoint_path is the empty string, which makes the same code path correct in both environments.
CONSTRUCTOR
new
Named parameters blob_endpoint and either account_name with account_key, or shared_access_signature. parse is the constructor to prefer, because it is the one that can derive an endpoint.
parse
my $connection = Azure::SDK::Storage::Blobs::ConnectionString->parse($text);
Class method. Parses and validates a connection string, croaking with a non-sensitive message when it is malformed.
METHODS
blob_endpoint
The normalized endpoint, without a trailing slash.
endpoint_path
The path component of the endpoint, without a trailing slash. Empty string when the endpoint has no path.
account_name
The storage account name.
credential
Returns a memoized Azure::SDK::Core::Credential::SharedKey built from the account name and key.
to_string
A log-safe summary. The account key is rendered as [REDACTED].
SEE ALSO
Azure::SDK::Storage::Blobs::Uri, Azure::SDK::Core::Credential::SharedKey