Пример #1
0
        private static async Task <ICloudBlob> GetLockBlobAsync(string accountConnectionString, string hostId)
        {
            CloudStorageAccount account = CloudStorageAccount.Parse(accountConnectionString);
            CloudBlobClient     client  = account.CreateCloudBlobClient();

            var container = client.GetContainerReference(PrimaryHostCoordinator.HostContainerName);

            await container.CreateIfNotExistsAsync();

            CloudBlockBlob blob = container.GetBlockBlobReference(PrimaryHostCoordinator.GetBlobName(hostId));

            if (!await blob.ExistsAsync())
            {
                await blob.UploadFromStreamAsync(new MemoryStream());
            }

            return(blob);
        }
        private static async Task <ICloudBlob> GetLockBlobAsync(string accountConnectionString, string hostId)
        {
            CloudStorageAccount account = CloudStorageAccount.Parse(accountConnectionString);
            CloudBlobClient     client  = account.CreateCloudBlobClient();

            var container = client.GetContainerReference(ScriptConstants.AzureWebJobsHostsContainerName);

            await container.CreateIfNotExistsAsync();

            // the StorageDistributedLockManager puts things under the /locks path by default
            CloudBlockBlob blob = container.GetBlockBlobReference("locks/" + PrimaryHostCoordinator.GetBlobName(hostId));

            if (!await blob.ExistsAsync())
            {
                await blob.UploadFromStreamAsync(new MemoryStream());
            }

            return(blob);
        }