public async Task CreateDeleteFileShare()
        {
            //create file share
            string    fileShareName = Recording.GenerateAssetName("testfileshare");
            FileShare share1        = (await _fileShareContainer.CreateOrUpdateAsync(fileShareName, new FileShareData())).Value;

            Assert.AreEqual(share1.Id.Name, fileShareName);

            //validate if created successfully
            FileShareData shareData = share1.Data;

            Assert.IsEmpty(shareData.Metadata);
            FileShare share2 = await _fileShareContainer.GetAsync(fileShareName);

            AssertFileShareEqual(share1, share2);
            Assert.IsTrue(await _fileShareContainer.CheckIfExistsAsync(fileShareName));
            Assert.IsFalse(await _fileShareContainer.CheckIfExistsAsync(fileShareName + "1"));

            //delete file share
            await share1.DeleteAsync();

            //validate if deleted successfully
            FileShare fileShare3 = await _fileShareContainer.GetIfExistsAsync(fileShareName);

            Assert.IsNull(fileShare3);
            Assert.IsFalse(await _fileShareContainer.CheckIfExistsAsync(fileShareName));
        }
Beispiel #2
0
        public async Task CreateLargeFileShareOnStorageAccount()
        {
            //create storage account and enable large share
            string accountName = await CreateValidAccountNameAsync(namePrefix);

            _resourceGroup = await CreateResourceGroupAsync();

            StorageAccountContainer storageAccountContainer = _resourceGroup.GetStorageAccounts();
            Sku sku = new Sku(SkuName.StandardLRS);
            StorageAccountCreateParameters parameters = GetDefaultStorageAccountParameters(sku: sku, kind: Kind.StorageV2);

            parameters.LargeFileSharesState = LargeFileSharesState.Enabled;
            StorageAccount account1 = (await storageAccountContainer.CreateOrUpdateAsync(accountName, parameters)).Value;

            VerifyAccountProperties(account1, false);

            //create file share with share quota 5200, which is allowed in large file shares
            string      fileShareName = Recording.GenerateAssetName("testfileshare");
            FileService fileService   = await account1.GetFileServices().GetAsync("default");

            FileShareContainer shareContainer = fileService.GetFileShares();
            FileShareData      shareData      = new FileShareData();

            shareData.ShareQuota = 5200;
            FileShareCreateOperation fileShareCreateOperation = await shareContainer.CreateOrUpdateAsync(fileShareName, shareData);

            FileShare share = await fileShareCreateOperation.WaitForCompletionAsync();

            Assert.AreEqual(share.Data.ShareQuota, shareData.ShareQuota);
        }
        public async Task CreateOrUpdate()
        {
            #region Snippet:Managing_FileShares_CreateFileShare
            FileShareContainer       fileShareContainer       = fileService.GetFileShares();
            string                   fileShareName            = "myFileShare";
            FileShareData            fileShareData            = new FileShareData();
            FileShareCreateOperation fileShareCreateOperation = await fileShareContainer.CreateOrUpdateAsync(fileShareName, fileShareData);

            FileShare fileShare = await fileShareCreateOperation.WaitForCompletionAsync();

            #endregion
        }