public RestAzureNS.AzureOperationResponse TriggerRestore() { string vaultName = (string)ProviderData[VaultParams.VaultName]; string resourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName]; string vaultLocation = (string)ProviderData[VaultParams.VaultLocation]; CmdletModel.AzureFileShareRecoveryPoint recoveryPoint = ProviderData[RestoreBackupItemParams.RecoveryPoint] as CmdletModel.AzureFileShareRecoveryPoint; string copyOptions = (string)ProviderData[RestoreFSBackupItemParams.ResolveConflict]; string sourceFilePath = ProviderData.ContainsKey(RestoreFSBackupItemParams.SourceFilePath) ? (string)ProviderData[RestoreFSBackupItemParams.SourceFilePath] : null; string sourceFileType = ProviderData.ContainsKey(RestoreFSBackupItemParams.SourceFileType) ? (string)ProviderData[RestoreFSBackupItemParams.SourceFileType] : null; string targetStorageAccountName = ProviderData.ContainsKey(RestoreFSBackupItemParams.TargetStorageAccountName) ? (string)ProviderData[RestoreFSBackupItemParams.TargetStorageAccountName] : null; string targetFileShareName = ProviderData.ContainsKey(RestoreFSBackupItemParams.TargetFileShareName) ? (string)ProviderData[RestoreFSBackupItemParams.TargetFileShareName] : null; string targetFolder = ProviderData.ContainsKey(RestoreFSBackupItemParams.TargetFolder) ? (string)ProviderData[RestoreFSBackupItemParams.TargetFolder] : null; string[] multipleSourceFilePaths = ProviderData.ContainsKey(RestoreFSBackupItemParams.MultipleSourceFilePath) ? (string[])ProviderData[RestoreFSBackupItemParams.MultipleSourceFilePath] : null; //validate file recovery request ValidateFileRestoreRequest(sourceFilePath, sourceFileType, multipleSourceFilePaths); //validate alternate location restore request ValidateLocationRestoreRequest(targetFileShareName, targetStorageAccountName, targetFolder); if (targetFileShareName != null && targetStorageAccountName != null && targetFolder == null) { targetFolder = "/"; } GenericResource storageAccountResource = ServiceClientAdapter.GetStorageAccountResource(recoveryPoint.ContainerName.Split(';')[2]); GenericResource targetStorageAccountResource = null; string targetStorageAccountLocation = null; if (targetStorageAccountName != null) { targetStorageAccountResource = ServiceClientAdapter.GetStorageAccountResource(targetStorageAccountName); targetStorageAccountLocation = targetStorageAccountResource.Location; } List <RestoreFileSpecs> restoreFileSpecs = null; TargetAFSRestoreInfo targetDetails = null; RestoreFileSpecs restoreFileSpec = new RestoreFileSpecs(); AzureFileShareRestoreRequest restoreRequest = new AzureFileShareRestoreRequest(); restoreRequest.CopyOptions = copyOptions; restoreRequest.SourceResourceId = storageAccountResource.Id; if (sourceFilePath != null) { restoreFileSpec.Path = sourceFilePath; restoreFileSpec.FileSpecType = sourceFileType; restoreRequest.RestoreRequestType = RestoreRequestType.ItemLevelRestore; if (targetFolder != null) { //scenario : item level restore for alternate location restoreFileSpec.TargetFolderPath = targetFolder; targetDetails = new TargetAFSRestoreInfo(); targetDetails.Name = targetFileShareName; targetDetails.TargetResourceId = targetStorageAccountResource.Id; restoreRequest.RecoveryType = RecoveryType.AlternateLocation; } else { //scenario : item level restore for original location restoreFileSpec.TargetFolderPath = null; restoreRequest.RecoveryType = RecoveryType.OriginalLocation; } restoreFileSpecs = new List <RestoreFileSpecs>(); restoreFileSpecs.Add(restoreFileSpec); } else if (multipleSourceFilePaths != null) { restoreFileSpecs = new List <RestoreFileSpecs>(); foreach (string filepath in multipleSourceFilePaths) { RestoreFileSpecs fileSpec = new RestoreFileSpecs(); fileSpec.Path = filepath; fileSpec.FileSpecType = sourceFileType; restoreRequest.RestoreRequestType = RestoreRequestType.ItemLevelRestore; if (targetFolder != null) { fileSpec.TargetFolderPath = targetFolder; targetDetails = new TargetAFSRestoreInfo(); targetDetails.Name = targetFileShareName; targetDetails.TargetResourceId = targetStorageAccountResource.Id; restoreRequest.RecoveryType = RecoveryType.AlternateLocation; } else { fileSpec.TargetFolderPath = null; restoreRequest.RecoveryType = RecoveryType.OriginalLocation; } restoreFileSpecs.Add(fileSpec); } } else { restoreRequest.RestoreRequestType = RestoreRequestType.FullShareRestore; if (targetFolder != null) { //scenario : full level restore for alternate location restoreFileSpec.Path = null; restoreFileSpec.TargetFolderPath = targetFolder; restoreFileSpec.FileSpecType = null; restoreFileSpecs = new List <RestoreFileSpecs>(); restoreFileSpecs.Add(restoreFileSpec); targetDetails = new TargetAFSRestoreInfo(); targetDetails.Name = targetFileShareName; targetDetails.TargetResourceId = targetStorageAccountResource.Id; restoreRequest.RecoveryType = RecoveryType.AlternateLocation; } else { //scenario : full level restore for original location restoreRequest.RecoveryType = RecoveryType.OriginalLocation; } } restoreRequest.RestoreFileSpecs = restoreFileSpecs; restoreRequest.TargetDetails = targetDetails; RestoreRequestResource triggerRestoreRequest = new RestoreRequestResource(); triggerRestoreRequest.Properties = restoreRequest; var response = ServiceClientAdapter.RestoreDisk( recoveryPoint, targetStorageAccountLocation = targetStorageAccountLocation ?? storageAccountResource.Location, triggerRestoreRequest, vaultName: vaultName, resourceGroupName: resourceGroupName, vaultLocation: vaultLocation ?? ServiceClientAdapter.BmsAdapter.GetResourceLocation()); return(response); }