Exemplo n.º 1
0
        public async virtual Task <FileShareCreateOperation> CreateOrUpdateAsync(string shareName, FileShareData fileShare, string expand = null, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (shareName == null)
            {
                throw new ArgumentNullException(nameof(shareName));
            }
            if (fileShare == null)
            {
                throw new ArgumentNullException(nameof(fileShare));
            }

            using var scope = _clientDiagnostics.CreateScope("FileShareContainer.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _restClient.CreateAsync(Id.ResourceGroupName, Id.Parent.Name, Id.Name, shareName, fileShare, expand, cancellationToken).ConfigureAwait(false);

                var operation = new FileShareCreateOperation(Parent, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 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
        }