public async Task createStorageAccountAndGetBlobContainerCollection() { ArmClient armClient = new ArmClient(new DefaultAzureCredential()); SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync(); string rgName = "myRgName"; AzureLocation location = AzureLocation.WestUS2; ArmOperation <ResourceGroupResource> operation = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, new ResourceGroupData(location)); ResourceGroupResource resourceGroup = operation.Value; this.resourceGroup = resourceGroup; StorageSku sku = new StorageSku(StorageSkuName.StandardGRS); StorageKind kind = StorageKind.Storage; string locationStr = "westus2"; StorageAccountCreateParameters parameters = new StorageAccountCreateParameters(sku, kind, locationStr); StorageAccountCollection accountCollection = resourceGroup.GetStorageAccounts(); string accountName = "myAccount"; ArmOperation <StorageAccountResource> accountCreateOperation = await accountCollection.CreateOrUpdateAsync(WaitUntil.Started, accountName, parameters); storageAccount = await accountCreateOperation.WaitForCompletionAsync(); #region Snippet:Managing_BlobContainers_GetBlobService BlobServiceResource blobService = storageAccount.GetBlobService(); #endregion this.blobService = blobService; }
public async Task createStorageAccountAndGetFileShareCollection() { ArmClient armClient = new ArmClient(new DefaultAzureCredential()); Subscription subscription = await armClient.GetDefaultSubscriptionAsync(); string rgName = "myRgName"; AzureLocation location = AzureLocation.WestUS2; ArmOperation <ResourceGroup> operation = await subscription.GetResourceGroups().CreateOrUpdateAsync(true, 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); StorageAccountCollection accountCollection = resourceGroup.GetStorageAccounts(); string accountName = "myAccount"; ArmOperation <StorageAccount> accountCreateOperation = await accountCollection.CreateOrUpdateAsync(false, accountName, parameters); storageAccount = await accountCreateOperation.WaitForCompletionAsync(); #region Snippet:Managing_FileShares_GetFileService FileService fileService = await storageAccount.GetFileService().GetAsync(); #endregion this.fileService = fileService; }
public async Task CreateOrUpdate() { #region Snippet:Managing_FileShares_CreateFileShare FileShareCollection fileShareCollection = fileService.GetFileShares(); string fileShareName = "myFileShare"; FileShareData fileShareData = new FileShareData(); ArmOperation <FileShareResource> fileShareCreateOperation = await fileShareCollection.CreateOrUpdateAsync(WaitUntil.Started, fileShareName, fileShareData); FileShareResource fileShare = await fileShareCreateOperation.WaitForCompletionAsync(); #endregion }
public async Task PITR() { //update storage account to v2 StorageAccountPatch updateParameters = new StorageAccountPatch() { Kind = StorageKind.StorageV2 }; _storageAccount = await _storageAccount.UpdateAsync(updateParameters); _blobService = await _blobService.GetAsync(); BlobServiceData properties = _blobService.Data; properties.DeleteRetentionPolicy = new DeleteRetentionPolicy(); properties.DeleteRetentionPolicy.Enabled = true; properties.DeleteRetentionPolicy.Days = 30; properties.ChangeFeed = new ChangeFeed(); properties.ChangeFeed.Enabled = true; properties.IsVersioningEnabled = true; properties.RestorePolicy = new RestorePolicyProperties(true) { Days = 5 }; _blobService = (await _blobService.CreateOrUpdateAsync(WaitUntil.Completed, properties)).Value; if (Mode != RecordedTestMode.Playback) { await Task.Delay(10000); } //create restore ranges //start restore BlobRestoreContent restoreContent = new BlobRestoreContent( Recording.Now.AddSeconds(-1).ToUniversalTime(), new List <BlobRestoreRange>() { new BlobRestoreRange("", "container1/blob1"), new BlobRestoreRange("container1/blob2", "container2/blob3"), new BlobRestoreRange("container3/blob3", "") }); ArmOperation <BlobRestoreStatus> restoreOperation = await _storageAccount.RestoreBlobRangesAsync(WaitUntil.Started, restoreContent); //wait for restore completion BlobRestoreStatus restoreStatus = await restoreOperation.WaitForCompletionAsync(); Assert.IsTrue(restoreStatus.Status == BlobRestoreProgressStatus.Complete || restoreStatus.Status == BlobRestoreProgressStatus.InProgress); }