public async Task createStorageAccountAndGetFileShareContainer() { ArmClient armClient = new ArmClient(new DefaultAzureCredential()); Subscription subscription = armClient.DefaultSubscription; string rgName = "myRgName"; Location location = Location.WestUS2; ResourceGroupCreateOrUpdateOperation operation = await subscription.GetResourceGroups().CreateOrUpdateAsync(rgName, new ResourceGroupData(location)); ResourceGroup resourceGroup = operation.Value; this.resourceGroup = resourceGroup; Sku sku = new Sku(SkuName.StandardGRS); Kind kind = Kind.Storage; string locationStr = "westus2"; StorageAccountCreateParameters parameters = new StorageAccountCreateParameters(sku, kind, locationStr); StorageAccountContainer accountContainer = resourceGroup.GetStorageAccounts(); string accountName = "myAccount"; StorageAccountCreateOperation accountCreateOperation = await accountContainer.CreateOrUpdateAsync(accountName, parameters); storageAccount = await accountCreateOperation.WaitForCompletionAsync(); #region Snippet:Managing_FileShares_GetFileService FileServiceContainer fileServiceContainer = storageAccount.GetFileServices(); FileService fileService = await fileServiceContainer.GetAsync("default"); #endregion this.fileService = fileService; }
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 CreateStorageAccountAndGetFileShareContainer() { _resourceGroup = await CreateResourceGroupAsync(); string accountName = await CreateValidAccountNameAsync("teststoragemgmt"); StorageAccountContainer storageAccountContainer = _resourceGroup.GetStorageAccounts(); _storageAccount = (await storageAccountContainer.CreateOrUpdateAsync(accountName, GetDefaultStorageAccountParameters())).Value; _fileServiceContainer = _storageAccount.GetFileServices(); _fileService = await _fileServiceContainer.GetAsync("default"); _fileShareContainer = _fileService.GetFileShares(); }