/// <summary> /// Gets protection policy operation status using the operation tracking URL /// </summary> /// <param name="url">Operation tracking URL</param> /// <returns>Operation status response returned by the service</returns> public BackUpOperationStatusResponse GetProtectionPolicyOperationStatusByURL(string url) { return(BmsAdapter.Client.GetOperationStatusByURLAsync( url, BmsAdapter.GetCustomRequestHeaders(), BmsAdapter.CmdletCancellationToken).Result); }
/// <summary> /// provision item level recovery connection identified by the input parameters /// </summary> /// <param name="containerName">Name of the container which the item belongs to</param> /// <param name="protectedItemName">Name of the item</param> /// <param name="recoveryPointId">ID of the recovery point</param> /// <param name="registrationRequest">registration request for ILR</param> /// <returns>Azure operation response returned by the service</returns> public RestAzureNS.AzureOperationResponse ProvisioninItemLevelRecoveryAccess ( string containerName, string protectedItemName, string recoveryPointId, ILRRequest registrationRequest ) { string resourceGroupName = BmsAdapter.GetResourceGroupName(); string resourceName = BmsAdapter.GetResourceName(); ILRRequestResource provisionRequest = new ILRRequestResource(); provisionRequest.Properties = registrationRequest; var response = BmsAdapter.Client.ItemLevelRecoveryConnections.ProvisionWithHttpMessagesAsync( resourceName, resourceGroupName, AzureFabricName, containerName, protectedItemName, recoveryPointId, provisionRequest, cancellationToken: BmsAdapter.CmdletCancellationToken).Result; return(response); }
/// <summary> /// Restores the disk based on the recovery point and other input parameters /// </summary> /// <param name="rp">Recovery point to restore the disk to</param> /// <param name="storageAccountId">ID of the storage account where to restore the disk</param> /// <param name="storageAccountLocation">Location of the storage account where to restore the disk</param> /// <param name="storageAccountType">Type of the storage account where to restore the disk</param> /// <returns>Job created by this operation</returns> public RestAzureNS.AzureOperationResponse RestoreDisk( AzureVmRecoveryPoint rp, string storageAccountId, string storageAccountLocation, string storageAccountType, bool osaOption) { var useOsa = ShouldUseOsa(rp, osaOption); string resourceGroupName = BmsAdapter.GetResourceGroupName(); string resourceName = BmsAdapter.GetResourceName(); string vaultLocation = BmsAdapter.GetResourceLocation(); Dictionary <UriEnums, string> uriDict = HelperUtils.ParseUri(rp.Id); string containerUri = HelperUtils.GetContainerUri(uriDict, rp.Id); string protectedItemUri = HelperUtils.GetProtectedItemUri(uriDict, rp.Id); string recoveryPointId = rp.RecoveryPointId; //validtion block if (storageAccountLocation != vaultLocation) { throw new Exception(Resources.RestoreDiskIncorrectRegion); } string vmType = containerUri.Split(';')[1].Equals("iaasvmcontainer", StringComparison.OrdinalIgnoreCase) ? "Classic" : "Compute"; string strType = storageAccountType.Equals("Microsoft.ClassicStorage/StorageAccounts", StringComparison.OrdinalIgnoreCase) ? "Classic" : "Compute"; if (vmType != strType) { throw new Exception(string.Format(Resources.RestoreDiskStorageTypeError, vmType)); } IaasVMRestoreRequest restoreRequest = new IaasVMRestoreRequest() { CreateNewCloudService = false, RecoveryPointId = recoveryPointId, RecoveryType = RecoveryType.RestoreDisks, Region = vaultLocation, StorageAccountId = storageAccountId, SourceResourceId = rp.SourceResourceId, OriginalStorageAccountOption = useOsa, }; RestoreRequestResource triggerRestoreRequest = new RestoreRequestResource(); triggerRestoreRequest.Properties = restoreRequest; var response = BmsAdapter.Client.Restores.TriggerWithHttpMessagesAsync( resourceName, resourceGroupName, AzureFabricName, containerUri, protectedItemUri, recoveryPointId, triggerRestoreRequest, cancellationToken: BmsAdapter.CmdletCancellationToken).Result; return(response); }
/// <summary> /// Lists jobs according to the parameters /// </summary> /// <param name="jobId">ID of the job</param> /// <param name="status">Status of the job</param> /// <param name="operation">Operation represented by the job</param> /// <param name="startTime">Time when the job started</param> /// <param name="endTime">Time when the job finished</param> /// <param name="backupManagementType">Backup management type of the item represented by the job</param> /// <param name="skipToken">Skip token pagination param</param> /// <returns>Job list response from the service</returns> public List <JobResource> GetJobs( string jobId, string status, string operation, DateTime startTime, DateTime endTime, string backupManagementType, string skipToken = null, string vaultName = null, string resourceGroupName = null) { ODataQuery <JobQueryObject> queryFilter = GetQueryObject( backupManagementType, startTime, endTime, jobId, status, operation); Func <RestAzureNS.IPage <JobResource> > listAsync = () => BmsAdapter.Client.BackupJobs.ListWithHttpMessagesAsync( vaultName ?? BmsAdapter.GetResourceName(), resourceGroupName ?? BmsAdapter.GetResourceGroupName(), queryFilter, skipToken, cancellationToken: BmsAdapter.CmdletCancellationToken).Result.Body; Func <string, RestAzureNS.IPage <JobResource> > listNextAsync = nextLink => BmsAdapter.Client.BackupJobs.ListNextWithHttpMessagesAsync( nextLink, cancellationToken: BmsAdapter.CmdletCancellationToken).Result.Body; return(HelperUtils.GetPagedList(listAsync, listNextAsync)); }
/// <summary> /// Lists recovery points from Secondary region for CRR /// </summary> /// <param name="containerName">Name of the container which the item belongs to</param> /// <param name="protectedItemName">Name of the item</param> /// <param name="queryFilter">Query filter</param> /// <returns>List of recovery points</returns> public List <RecoveryPointResource> GetRecoveryPointsFromSecondaryRegion( string containerName, string protectedItemName, ODataQuery <BMSRPQueryObject> queryFilter, string vaultName = null, string resourceGroupName = null) { Func <RestAzureNS.IPage <RecoveryPointResource> > listAsync = () => BmsAdapter.Client.RecoveryPointsCrr.ListWithHttpMessagesAsync( vaultName ?? BmsAdapter.GetResourceName(), resourceGroupName ?? BmsAdapter.GetResourceGroupName(), AzureFabricName, containerName, protectedItemName, queryFilter, cancellationToken: BmsAdapter.CmdletCancellationToken).Result.Body; Func <string, RestAzureNS.IPage <RecoveryPointResource> > listNextAsync = nextLink => BmsAdapter.Client.RecoveryPointsCrr.ListNextWithHttpMessagesAsync( nextLink, cancellationToken: BmsAdapter.CmdletCancellationToken).Result.Body; var response = HelperUtils.GetPagedList(listAsync, listNextAsync); return(response); }
/// <summary> /// Restores the disk based on the recovery point and other input parameters /// </summary> /// <param name="rp">Recovery point to restore the disk to</param> /// <param name="storageAccountId">ID of the storage account where to restore the disk</param> /// <param name="storageAccountLocation">Location of the storage account where to restore the disk</param> /// <param name="storageAccountType">Type of the storage account where to restore the disk</param> /// <returns>Job created by this operation</returns> public RestAzureNS.AzureOperationResponse RestoreDisk( AzureRecoveryPoint rp, string storageAccountLocation, RestoreRequestResource triggerRestoreRequest, string vaultName = null, string resourceGroupName = null, string vaultLocation = null) { Dictionary <UriEnums, string> uriDict = HelperUtils.ParseUri(rp.Id); string containerUri = HelperUtils.GetContainerUri(uriDict, rp.Id); string protectedItemUri = HelperUtils.GetProtectedItemUri(uriDict, rp.Id); string recoveryPointId = rp.RecoveryPointId; //validtion block if (storageAccountLocation != vaultLocation) { throw new Exception(Resources.TriggerRestoreIncorrectRegion); } var response = BmsAdapter.Client.Restores.TriggerWithHttpMessagesAsync( vaultName ?? BmsAdapter.GetResourceName(), resourceGroupName ?? BmsAdapter.GetResourceGroupName(), AzureFabricName, containerUri, protectedItemUri, recoveryPointId, triggerRestoreRequest, cancellationToken: BmsAdapter.CmdletCancellationToken).Result; return(response); }
CreateOrUpdateProtectionPolicy( string policyName, ProtectionPolicyResource request, string vaultName = null, string resourceGroupName = null, string auxiliaryAccessToken = "", bool isMUAProtected = false) { Dictionary <string, List <string> > customHeaders = new Dictionary <string, List <string> >(); string operationRequest = null; if (isMUAProtected) { List <ResourceGuardProxyBaseResource> resourceGuardMapping = ListResourceGuardMapping(vaultName, resourceGroupName); if (resourceGuardMapping != null && resourceGuardMapping.Count != 0) { foreach (ResourceGuardOperationDetail operationDetail in resourceGuardMapping[0].Properties.ResourceGuardOperationDetails) { if (operationDetail.VaultCriticalOperation == "Microsoft.RecoveryServices/vaults/backupPolicies/write") { operationRequest = operationDetail.DefaultResourceRequest; } } if (operationRequest != null) { request.Properties.ResourceGuardOperationRequests = new List <string>(); request.Properties.ResourceGuardOperationRequests.Add(operationRequest); } } } if (auxiliaryAccessToken != null && auxiliaryAccessToken != "") { if (operationRequest != null) { customHeaders.Add("x-ms-authorization-auxiliary", new List <string> { "Bearer " + auxiliaryAccessToken }); } else if (!isMUAProtected) { throw new ArgumentException(String.Format(Resources.PolicyUpdateNotCritical)); } else { throw new ArgumentException(String.Format(Resources.UnexpectedParameterToken, "ModifyPolicy")); } } return(BmsAdapter.Client.ProtectionPolicies.CreateOrUpdateWithHttpMessagesAsync( vaultName ?? BmsAdapter.GetResourceName(), resourceGroupName ?? BmsAdapter.GetResourceGroupName(), policyName, request, customHeaders, cancellationToken: BmsAdapter.CmdletCancellationToken).Result); }
/// <summary> /// Gets a protection policy given the name /// </summary> /// <param name="policyName">Name of the policy</param> /// <returns>Policy response returned by the service</returns> public ProtectionPolicyResource GetProtectionPolicy(string policyName) { return(BmsAdapter.Client.ProtectionPolicies.GetWithHttpMessagesAsync( BmsAdapter.GetResourceName(), BmsAdapter.GetResourceGroupName(), policyName, cancellationToken: BmsAdapter.CmdletCancellationToken).Result.Body); }
GetProtectionPolicyOperationStatus(string policyName, string operationId) { string resourceName = BmsAdapter.GetResourceName(); string resourceGroupName = BmsAdapter.GetResourceGroupName(); return(BmsAdapter.Client.ProtectionPolicyOperationStatuses.GetWithHttpMessagesAsync( resourceName, resourceGroupName, policyName, operationId).Result); }
GetProtectedItemOperationStatus(string operationId) { string resourceName = BmsAdapter.GetResourceName(); string resourceGroupName = BmsAdapter.GetResourceGroupName(); return(BmsAdapter.Client.BackupOperationStatuses.GetWithHttpMessagesAsync( resourceName, resourceGroupName, operationId).Result); }
public BaseRecoveryServicesJobResponse RestoreDisk(AzureVmRecoveryPoint rp, string storageAccountId, string storageAccountLocation, string storageAccountType) { string resourceGroupName = BmsAdapter.GetResourceGroupName(); string resourceName = BmsAdapter.GetResourceName(); string vaultLocation = BmsAdapter.GetResourceLocation(); string containerName = rp.ContainerName; string protectedItemName = rp.ItemName; string recoveryPointId = rp.RecoveryPointId; //validtion block if (storageAccountLocation != vaultLocation) { throw new Exception(Resources.RestoreDiskIncorrectRegion); } string vmType = containerName.Split(';')[1].Equals("iaasvmcontainer", StringComparison.OrdinalIgnoreCase) ? "Classic" : "Compute"; string strType = storageAccountType.Equals("Microsoft.ClassicStorage/StorageAccounts", StringComparison.OrdinalIgnoreCase) ? "Classic" : "Compute"; if (vmType != strType) { throw new Exception(String.Format(Resources.RestoreDiskStorageTypeError, vmType)); } IaasVMRestoreRequest restoreRequest = new IaasVMRestoreRequest() { AffinityGroup = String.Empty, CloudServiceOrResourceGroup = String.Empty, CreateNewCloudService = false, RecoveryPointId = recoveryPointId, RecoveryType = RecoveryType.RestoreDisks, Region = vaultLocation, StorageAccountId = storageAccountId, SubnetId = string.Empty, VirtualMachineName = string.Empty, VirtualNetworkId = string.Empty, }; TriggerRestoreRequest triggerRestoreRequest = new TriggerRestoreRequest(); triggerRestoreRequest.Item = new RestoreRequestResource(); triggerRestoreRequest.Item.Properties = new RestoreRequest(); triggerRestoreRequest.Item.Properties = restoreRequest; var response = BmsAdapter.Client.Restores.TriggerRestoreAsync( resourceGroupName, resourceName, BmsAdapter.GetCustomRequestHeaders(), AzureFabricName, containerName, protectedItemName, recoveryPointId, triggerRestoreRequest, BmsAdapter.CmdletCancellationToken).Result; return(response); }
/// <summary> /// Gets a protection policy given the name /// </summary> /// <param name="policyName">Name of the policy</param> /// <returns>Policy response returned by the service</returns> public ProtectionPolicyResponse GetProtectionPolicy(string policyName) { return(BmsAdapter.Client.ProtectionPolicies.GetAsync( BmsAdapter.GetResourceGroupName(), BmsAdapter.GetResourceName(), policyName, BmsAdapter.GetCustomRequestHeaders(), BmsAdapter.CmdletCancellationToken).Result); }
/// <summary> /// Deletes protection policy from the vault specified by the name /// </summary> /// <param name="policyName">Name of the policy to be deleted</param> /// <returns>Default azure operation response</returns> public RestAzureNS.AzureOperationResponse RemoveProtectionPolicy( string policyName) { return(BmsAdapter.Client.ProtectionPolicies.DeleteWithHttpMessagesAsync( BmsAdapter.GetResourceName(), BmsAdapter.GetResourceGroupName(), policyName, cancellationToken: BmsAdapter.CmdletCancellationToken).Result); }
CreateOrUpdateProtectionPolicy(string policyName, ProtectionPolicyResource request) { return(BmsAdapter.Client.ProtectionPolicies.CreateOrUpdateWithHttpMessagesAsync( BmsAdapter.GetResourceName(), BmsAdapter.GetResourceGroupName(), policyName, request, cancellationToken: BmsAdapter.CmdletCancellationToken).Result); }
/// <summary> /// Gets result of the cancel operation on the job using the operation ID /// </summary> /// <param name="operationId">ID of the operation in progress</param> /// <returns></returns> public RestAzureNS.AzureOperationResponse GetCancelJobOperationResult( string operationId) { string resourceName = BmsAdapter.GetResourceName(); string resourceGroupName = BmsAdapter.GetResourceGroupName(); return(BmsAdapter.Client.JobOperationResults.GetWithHttpMessagesAsync( resourceName, resourceGroupName, AzureFabricName, operationId).Result); }
/// <summary> /// Deletes protection policy from the vault specified by the name /// </summary> /// <param name="policyName">Name of the policy to be deleted</param> public AzureOperationResponse RemoveProtectionPolicy( string policyName) { return(BmsAdapter.Client.ProtectionPolicies.DeleteAsync( BmsAdapter.GetResourceGroupName(), BmsAdapter.GetResourceName(), policyName, BmsAdapter.GetCustomRequestHeaders(), BmsAdapter.CmdletCancellationToken).Result); }
/// <summary> /// Gets result of the refresh operation on the protection container using the operation ID /// </summary> /// <param name="operationId">ID of the operation in progress</param> /// <returns></returns> public RestAzureNS.AzureOperationResponse GetRefreshContainerOperationResult( string operationId) { string resourceName = BmsAdapter.GetResourceName(); string resourceGroupName = BmsAdapter.GetResourceGroupName(); return(BmsAdapter.Client.ProtectionContainerRefreshOperationResults .GetWithHttpMessagesAsync( resourceName, resourceGroupName, AzureFabricName, operationId).Result); }
/// <summary> /// Lists protection policies according to the input query filter /// </summary> /// <param name="queryFilter">Query filter</param> /// <returns>List of protection policies</returns> public ProtectionPolicyListResponse ListProtectionPolicy( ProtectionPolicyQueryParameters queryFilter) { return(BmsAdapter.Client.ProtectionPolicies.ListAsync( BmsAdapter.GetResourceGroupName(), BmsAdapter.GetResourceName(), queryFilter, BmsAdapter.GetCustomRequestHeaders(), BmsAdapter.CmdletCancellationToken).Result); }
public BaseRecoveryServicesJobResponse GetRefreshContainerOperationResultByURL( string operationResultLink) { string resourceName = BmsAdapter.GetResourceName(); string resourceGroupName = BmsAdapter.GetResourceGroupName(); return(BmsAdapter.Client.Containers.GetRefreshOperationResultByURLAsync( operationResultLink, BmsAdapter.CmdletCancellationToken).Result); }
GetProtectedItemOperationStatus( string operationId, string vaultName = null, string resourceGroupName = null) { return(BmsAdapter.Client.BackupOperationStatuses.GetWithHttpMessagesAsync( vaultName ?? BmsAdapter.GetResourceName(), resourceGroupName ?? BmsAdapter.GetResourceGroupName(), operationId).Result); }
/// <summary> /// Gets result of the cancel operation on the job using the operation ID /// </summary> /// <param name="operationId">ID of the operation in progress</param> /// <returns></returns> public RestAzureNS.AzureOperationResponse GetCancelJobOperationResult( string operationId, string vaultName = null, string resourceGroupName = null) { return(BmsAdapter.Client.JobOperationResults.GetWithHttpMessagesAsync( vaultName ?? BmsAdapter.GetResourceName(), resourceGroupName ?? BmsAdapter.GetResourceGroupName(), AzureFabricName, operationId).Result); }
/// <summary> /// Gets a job /// </summary> /// <param name="jobId">ID of the job</param> /// <returns>Job response returned by the service</returns> public JobResource GetJob(string jobId) { string resourceName = BmsAdapter.GetResourceName(); string resourceGroupName = BmsAdapter.GetResourceGroupName(); return(BmsAdapter.Client.JobDetails.GetWithHttpMessagesAsync( resourceName, resourceGroupName, jobId, cancellationToken: BmsAdapter.CmdletCancellationToken).Result.Body); }
public BackUpOperationStatusResponse GetProtectedItemOperationStatusByURL( string operationResultLink) { string resourceName = BmsAdapter.GetResourceName(); string resourceGroupName = BmsAdapter.GetResourceGroupName(); return(BmsAdapter.Client.GetOperationStatusByURLAsync( operationResultLink, BmsAdapter.GetCustomRequestHeaders(), BmsAdapter.CmdletCancellationToken).Result); }
public BaseRecoveryServicesJobResponse TriggerBackup(string containerName, string itemName) { return(BmsAdapter.Client.Backups.TriggerBackupAsync( BmsAdapter.GetResourceGroupName(), BmsAdapter.GetResourceName(), BmsAdapter.GetCustomRequestHeaders(), ServiceClientAdapter.AzureFabricName, containerName, itemName, BmsAdapter.CmdletCancellationToken).Result); }
/// <summary> /// Gets a job /// </summary> /// <param name="jobId">ID of the job</param> /// <returns>Job response returned by the service</returns> public JobResource GetJob( string jobId, string vaultName = null, string resourceGroupName = null) { return(BmsAdapter.Client.JobDetails.GetWithHttpMessagesAsync( vaultName ?? BmsAdapter.GetResourceName(), resourceGroupName ?? BmsAdapter.GetResourceGroupName(), jobId, cancellationToken: BmsAdapter.CmdletCancellationToken).Result.Body); }
/// <summary> /// Cancels a job /// </summary> /// <param name="jobId">ID of the job to cancel</param> /// <returns>Cancelled job response from the service</returns> public RestAzureNS.AzureOperationResponse CancelJob( string jobId, string vaultName = null, string resourceGroupName = null) { return(BmsAdapter.Client.JobCancellations.TriggerWithHttpMessagesAsync( vaultName ?? BmsAdapter.GetResourceName(), resourceGroupName ?? BmsAdapter.GetResourceGroupName(), jobId, cancellationToken: BmsAdapter.CmdletCancellationToken).Result); }
GetProtectionPolicyOperationStatus( string policyName, string operationId, string vaultName = null, string resourceGroupName = null) { return(BmsAdapter.Client.ProtectionPolicyOperationStatuses.GetWithHttpMessagesAsync( vaultName ?? BmsAdapter.GetResourceName(), resourceGroupName ?? BmsAdapter.GetResourceGroupName(), policyName, operationId).Result); }
/// <summary> /// Fetches protection containers in the vault according to the query params /// </summary> /// <param name="parameters"></param> /// <returns></returns> public IEnumerable <ProtectionContainerResource> ListContainers( ProtectionContainerListQueryParams queryParams) { var listResponse = BmsAdapter.Client.Containers.ListAsync( BmsAdapter.GetResourceGroupName(), BmsAdapter.GetResourceName(), queryParams, BmsAdapter.GetCustomRequestHeaders(), BmsAdapter.CmdletCancellationToken).Result; return(listResponse.ItemList.ProtectionContainers); }
/// <summary> /// Deletes a protection intent /// </summary> /// <param name="protectedItemName">Name of the item</param> /// <param name="request">Protected item create or update request</param> /// <returns>Job created in the service for this operation</returns> public RestAzureNS.AzureOperationResponse DeleteProtectionIntent( string protectedItemName, string vaultName = null, string resourceGroupName = null) { return(BmsAdapter.Client.ProtectionIntent.DeleteWithHttpMessagesAsync( vaultName ?? BmsAdapter.GetResourceName(), resourceGroupName ?? BmsAdapter.GetResourceGroupName(), AzureFabricName, protectedItemName, cancellationToken: BmsAdapter.CmdletCancellationToken).Result); }
/// <summary> /// Creates a new policy or updates an already existing policy /// </summary> /// <param name="policyName">Name of the policy</param> /// <param name="request">Policy create or update request</param> /// <returns>Policy created by this operation</returns> public ProtectionPolicyResponse CreateOrUpdateProtectionPolicy( string policyName, ProtectionPolicyRequest request) { return(BmsAdapter.Client.ProtectionPolicies.CreateOrUpdateAsync( BmsAdapter.GetResourceGroupName(), BmsAdapter.GetResourceName(), policyName, request, BmsAdapter.GetCustomRequestHeaders(), BmsAdapter.CmdletCancellationToken).Result); }