Exemplo n.º 1
0
        public async Task <IUpdateBlob> TryLockUpdateBlob(string appId)
        {
            string     updateBlobName = GetUpdateBlobName(appId);
            ICloudBlob blob           = GetBlob(updateBlobName);
            await BlobUtils.CreateBlobIfNotExists(blob);

            UpdateBlob updateBlob = new UpdateBlob(blob, _blobLeaseFactory);
            bool       locked     = await updateBlob.TryLock();

            if (locked == false)
            {
                throw new UpdateBlobUnavailableException();
            }
            return(updateBlob);
        }
Exemplo n.º 2
0
        public async Task TestCreateBlobIfNotExists()
        {
            var container = _blobClient.GetContainerReference("container");

            container.CreateIfNotExists();
            var blob = container.GetBlockBlobReference("createIfNotExistsTestBlob.txt");
            await BlobUtils.CreateBlobIfNotExists(blob);

            Assert.True(await blob.ExistsAsync());
            string text = "test content";
            await blob.UploadTextAsync(text);

            await BlobUtils.CreateBlobIfNotExists(blob);

            Assert.Equal(text, await blob.DownloadTextAsync());
        }