コード例 #1
0
        private CloudBlockBlob GetBlobReference()
        {
            string connectionString       = _primaryStorageConfiguration.ConnectionString;
            bool   readAccessGeoRedundant = _primaryStorageConfiguration.ReadAccessGeoRedundant;

            if (_alternateBlobStorageConfiguration != null && _featureFlagService.IsAlternateStatisticsSourceEnabled())
            {
                connectionString       = _alternateBlobStorageConfiguration.ConnectionString;
                readAccessGeoRedundant = _alternateBlobStorageConfiguration.ReadAccessGeoRedundant;
            }

            var storageAccount = CloudStorageAccount.Parse(connectionString);
            var blobClient     = storageAccount.CreateCloudBlobClient();

            if (readAccessGeoRedundant)
            {
                blobClient.DefaultRequestOptions.LocationMode = LocationMode.PrimaryThenSecondary;
            }

            var container = blobClient.GetContainerReference(StatsContainerName);
            var blob      = container.GetBlockBlobReference(DownloadCountBlobName);

            if (!blob.Exists())
            {
                return(null);
            }
            return(blob);
        }