/// <summary> /// ProcessRecord of the command. /// </summary> public override void ExecuteSiteRecoveryCmdlet() { base.ExecuteSiteRecoveryCmdlet(); string armName = string.Format( "StrgMap_{0}_{1}_{2}", PrimaryStorageClassification.Name, RecoveryStorageClassification.Name, Guid.NewGuid()); var props = new StorageClassificationMappingInputProperties() { TargetStorageClassificationId = RecoveryStorageClassification.Id }; var input = new StorageClassificationMappingInput() { Properties = props }; LongRunningOperationResponse operationResponse = RecoveryServicesClient.MapStorageClassification( PrimaryStorageClassification, input, armName); JobResponse jobResponse = RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( PSRecoveryServicesClient.GetJobIdFromReponseLocation(operationResponse.Location)); base.WriteObject(new ASRJob(jobResponse.Job)); }
public void PairUnpairStorageClassifications() { using (UndoContext context = UndoContext.Current) { context.Start(); var client = GetSiteRecoveryClient(CustomHttpHandler); FabricListResponse responseServers = client.Fabrics.List(RequestHeaders); foreach (Fabric fabric in responseServers.Fabrics) { if (fabric.Properties.CustomDetails.InstanceType == "VMM") { var storageClassifications = client.StorageClassification.List(fabric.Name, RequestHeaders); if (storageClassifications.StorageClassifications.Count > 1) { StorageClassificationMappingInputProperties mapProps = new StorageClassificationMappingInputProperties() { TargetStorageClassificationId = storageClassifications.StorageClassifications[1].Id }; StorageClassificationMappingInput mapInput = new StorageClassificationMappingInput() { Properties = mapProps }; string mappingName = "StorageClassificationMapping-" + (new Random()).Next(); var pairResp = client.StorageClassificationMapping.PairStorageClassification( fabric.Name, storageClassifications.StorageClassifications[0].Name, mappingName, mapInput, RequestHeaders); var mappings = client.StorageClassificationMapping.List( fabric.Name, storageClassifications.StorageClassifications[0].Name, RequestHeaders); var mapping = client.StorageClassificationMapping.Get( fabric.Name, storageClassifications.StorageClassifications[0].Name, mappings.StorageClassificationMappings[0].Name, RequestHeaders); var unpairResp = client.StorageClassificationMapping.UnpairStorageClassification( fabric.Name, storageClassifications.StorageClassifications[0].Name, mappingName, RequestHeaders); } } } } }
public static StorageClassificationMappingOperationResponse PairStorageClassification( this SiteRecoveryManagementClient client, Fabric primaryFabric, StorageClassification primaryClassification, StorageClassification recoveryClassification, string armResourceName) { StorageClassificationMappingInputProperties props = new StorageClassificationMappingInputProperties() { TargetStorageClassificationId = recoveryClassification.Id }; StorageClassificationMappingInput input = new StorageClassificationMappingInput() { Properties = props }; return(client.StorageClassificationMapping.PairStorageClassification( primaryFabric.Name, primaryClassification.Name, armResourceName, input, GetRequestHeaders()) as StorageClassificationMappingOperationResponse); }