public AzurePath()

in dotnet/Utils/RichPath.cs [221:282]


        public AzurePath(string azureInfoPath, string path)
        {
            if (!path.StartsWith(AZURE_PATH_PREFIX))
            {
                throw new ArgumentException($"Azure paths need to be in the format {AZURE_PATH_PREFIX}/account_name/container_name/path, but got {path}.");
            }

            // Strip off azure:// prefix:
            var accountPath = path.Substring(AZURE_PATH_PREFIX.Length);
            var pathParts = accountPath.Split(new char[] { '/' }, 3);

            if (pathParts.Length < 3)
            {
                throw new ArgumentException($"Azure paths need to be in the format {AZURE_PATH_PREFIX}/account_name/container_name/path, but got {path}.");
            }
            var (accountName, containerName, containerPath) = (pathParts[0], pathParts[1], pathParts[2]);

            using (var azureInfoInstream = File.OpenText(azureInfoPath))
            using (var azureInfoJsonReader = new JsonTextReader(azureInfoInstream))
            {
                var deserializer = new JsonSerializer();
                var azureInfo = deserializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(
                    azureInfoJsonReader);

                if (!azureInfo.TryGetValue(accountName, out var accountInfo))
                {
                    throw new ArgumentException($"Could not find access information for account '{accountName}'!");
                }

                StorageCredentials storageCredentials;
                if (accountInfo.TryGetValue("sas_token", out var sasToken))
                {
                    storageCredentials = new StorageCredentials(sasToken);
                }
                else if (accountInfo.TryGetValue("account_key", out var accountKey))
                {
                    storageCredentials = new StorageCredentials(accountName: accountName, keyValue: accountKey);
                }
                else
                {
                    throw new ArgumentException(
                        $"Access to Azure storage account {accountName} requires either account_key or sas_token!");
                }

                var storageAccount = new CloudStorageAccount(storageCredentials, useHttps: true, accountName: accountName, endpointSuffix: "core.windows.net");

                if (accountInfo.TryGetValue("cache_location", out string cacheLocation))
                {
                    // Replace environment variables in the cache location
                    cacheLocation = Regex.Replace(
                        cacheLocation,
                        "${([^}]+)}",
                        match => Environment.GetEnvironmentVariable(match.Groups[0].Value) ?? match.Value);
                }

                this.accountName = accountName;
                this.containerName = containerName;
                this.cacheLocation = cacheLocation;
                blobContainerClient = storageAccount.CreateCloudBlobClient().GetContainerReference(this.containerName);
                Path = containerPath;
            }
        }