public override void ExecuteCmdlet() { var updateParameter = new Management.FrontDoor.Models.RulesEngine( name: Name, rules: Rule?.Select(x => x.ToSdkRulesEngineRule()).ToList() ); try { var rulesEngine = FrontDoorManagementClient.RulesEngines.CreateOrUpdate( resourceGroupName: ResourceGroupName, frontDoorName: FrontDoorName, rulesEngineName: Name, rulesEngineParameters: updateParameter ); WriteObject(rulesEngine.ToPSRulesEngine()); } catch (Microsoft.Azure.Management.FrontDoor.Models.ErrorResponseException e) { throw new PSArgumentException(string.Format(Resources.Error_ErrorResponseFromServer, e.Response.Content)); } }
public override void ExecuteCmdlet() { if (ParameterSetName == ObjectParameterSet) { ResourceIdentifier identifier = new ResourceIdentifier(InputObject.Id); ResourceGroupName = identifier.ResourceGroupName; FrontDoorName = identifier.ParentResource.Substring(identifier.ParentResource.IndexOf("/") + 1); Name = InputObject.Name; } else if (ParameterSetName == ResourceIdParameterSet) { ResourceIdentifier identifier = new ResourceIdentifier(ResourceId); ResourceGroupName = identifier.ResourceGroupName; FrontDoorName = identifier.ParentResource.Substring(identifier.ParentResource.IndexOf("/") + 1); Name = InputObject.Name; } // Retrieve existing Rules Engine try { var rulesEngine = FrontDoorManagementClient.RulesEngines.Get(ResourceGroupName, FrontDoorName, Name); } catch (Microsoft.Azure.Management.FrontDoor.Models.ErrorResponseException e) { if (e.Response.StatusCode.Equals(HttpStatusCode.NotFound)) { throw new PSArgumentException(string.Format(Resources.Error_RulesEngineNotFound, Name, FrontDoorName)); } } RulesEngine updateParameter; if (ParameterSetName == ObjectParameterSet) { updateParameter = InputObject.ToSdkRulesEngine(); } else { updateParameter = new Management.FrontDoor.Models.RulesEngine( rules: Rule?.Select(x => x.ToSdkRulesEngineRule()).ToList() ); } if (ShouldProcess(Resources.FrontDoorTarget, string.Format(Resources.RulesEngineChangeWarning, Name, FrontDoorName))) { try { var rulesEngine = FrontDoorManagementClient.RulesEngines.CreateOrUpdate( resourceGroupName: ResourceGroupName, frontDoorName: FrontDoorName, rulesEngineName: Name, rulesEngineParameters: updateParameter ); WriteObject(rulesEngine.ToPSRulesEngine()); } catch (Microsoft.Azure.Management.FrontDoor.Models.ErrorResponseException e) { throw new PSArgumentException(string.Format(Resources.Error_ErrorResponseFromServer, e.Response.Content)); } } }