diff --git a/src/Network/Network.Test/NrpTeamAlias.cs b/src/Network/Network.Test/NrpTeamAlias.cs index e01c2d64539a..3cb7c501f650 100644 --- a/src/Network/Network.Test/NrpTeamAlias.cs +++ b/src/Network/Network.Test/NrpTeamAlias.cs @@ -64,5 +64,8 @@ class NrpTeamAlias // Azure Network IPAM dev team public const string ipam = "ipamdev"; + + // Azure Network Billing and Telemetry team + public const string billingandtelemetry = "azurenetworkbilling"; } } diff --git a/src/Network/Network.Test/ScenarioTests/CustomIpPrefixTests.cs b/src/Network/Network.Test/ScenarioTests/CustomIpPrefixTests.cs new file mode 100644 index 000000000000..e78ab7c7c2c8 --- /dev/null +++ b/src/Network/Network.Test/ScenarioTests/CustomIpPrefixTests.cs @@ -0,0 +1,37 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Commands.Network.Test.ScenarioTests; +using Microsoft.WindowsAzure.Commands.ScenarioTest; +using Xunit; + +namespace Commands.Network.Test.ScenarioTests +{ + + public class CustomIpPrefixTests : NetworkTestRunner + { + public CustomIpPrefixTests(Xunit.Abstractions.ITestOutputHelper output) + : base(output) + { + } + + [Fact(Skip = "Resource currently in private preview, testing requires very specific conditions, will implement these tests in future.")] + [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.Owner, NrpTeamAlias.billingandtelemetry)] + public void TestCustomIpPrefixCRUD() + { + TestRunner.RunTestScript("Test-CustomIpPrefixCRUD"); + } + } +} diff --git a/src/Network/Network.Test/ScenarioTests/CustomIpPrefixTests.ps1 b/src/Network/Network.Test/ScenarioTests/CustomIpPrefixTests.ps1 new file mode 100644 index 000000000000..5a6eb17630f5 --- /dev/null +++ b/src/Network/Network.Test/ScenarioTests/CustomIpPrefixTests.ps1 @@ -0,0 +1,117 @@ +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.SYNOPSIS +Tests CRUD operations on a simple customIpPrefix. + +NOTE: This feature is currently in private preview, so updated binaries are on test slice in canary only and is currently un-reacheable via the production manifest. +Testing has been done locally using the brazilus ARM endpoint and a specific subscription that has the necessary flags to run these cmdlets. +#> +function Test-CustomIpPrefixCRUD +{ + # Setup + $rgname = "powershell-test-rg" + $rname = "testCustomIpPrefix" + $location = "eastus2euap" + $cidr = "40.40.40.0/24" + + try + { + # Create the resource group + $resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation + + # Create customIpPrefix + $job = New-AzCustomIpPrefix -Name $rname -ResourceGroupName $rgname -location $location -Cidr $cidr -AsJob + $job | Wait-Job + $job | Receive-Job + + # get by name and resource group + $actual = Get-AzCustomIpPrefix -ResourceGroupName $rgname -name $rname + Assert-AreEqual $actual.ResourceGroupName $rgname + Assert-AreEqual $actual.Name $rname + Assert-AreEqual $actual.Location $location + Assert-AreEqual $actual.Cidr $cidr + Assert-AreEqual $actual.PublicIpPrefixes.Count 0 + Assert-NotNull $actual.ResourceGuid + Assert-AreEqual $actual.ProvisioningState "Succeeded" + + # get by resource id + $actual = Get-AzCustomIpPrefix -ResourceId $actual.Id + Assert-AreEqual $actual.ResourceGroupName $rgname + Assert-AreEqual $actual.Name $rname + Assert-AreEqual $actual.Location $location + Assert-AreEqual $actual.Cidr $cidr + Assert-AreEqual $actual.PublicIpPrefixes.Count 0 + Assert-NotNull $actual.ResourceGuid + Assert-AreEqual $actual.ProvisioningState "Succeeded" + + # get by input object + $actual = Get-AzCustomIpPrefix -InputObject $actual + Assert-AreEqual $actual.ResourceGroupName $rgname + Assert-AreEqual $actual.Name $rname + Assert-AreEqual $actual.Location $location + Assert-AreEqual $actual.Cidr $cidr + Assert-AreEqual $actual.PublicIpPrefixes.Count 0 + Assert-NotNull $actual.ResourceGuid + Assert-AreEqual $actual.ProvisioningState "Succeeded" + + # list + $list = Get-AzCustomIpPrefix -ResourceGroupName $rgname + Assert-AreEqual 1 @($list).Count + Assert-AreEqual $list[0].ResourceGroupName $actual.ResourceGroupName + Assert-AreEqual $list[0].Name $actual.Name + Assert-AreEqual $list[0].Location $actual.Location + Assert-AreEqual $list[0].Cidr $actual.Cidr + Assert-AreEqual $list[0].PublicIpPrefixes.Count 0 + Assert-AreEqual $list[0].ProvisioningState "Succeeded" + + # delete + $job = Remove-AzCustomIpPrefix -InputObject $actual -PassThru -Force -AsJob + $job | Wait-Job + $delete = $job | Receive-Job + Assert-AreEqual true $delete + + $list = Get-AzPublicIpPrefix -ResourceGroupName $rgname + Assert-AreEqual 0 @($list).Count + + # Try setting unexisting + Assert-ThrowsLike { Update-AzPublicIpPrefix -PublicIpPrefix $expected } "*not found*" + + # Create one more time to test deletion with resource id parameter set + $job = New-AzCustomIpPrefix -Name $rname -ResourceGroupName $rgname -location $location -Cidr $cidr -AsJob + $job | Wait-Job + $expected = $job | Receive-Job + + $job = Remove-AzPublicIpPrefix -ResourceId $expected.Id -PassThru -Force -AsJob + $job | Wait-Job + $delete = $job | Receive-Job + Assert-AreEqual true $delete + + # Create one more time to test deletion with resource group and name + $job = New-AzCustomIpPrefix -Name $rname -ResourceGroupName $rgname -location $location -Cidr $cidr -AsJob + $job | Wait-Job + $expected = $job | Receive-Job + + $job = Remove-AzPublicIpPrefix -Name $rname -ResourceGroupName $rgname + $job | Wait-Job + $delete = $job | Receive-Job + Assert-AreEqual true $delete + } + finally + { + # Cleanup + Clean-ResourceGroup $rgname + } +} \ No newline at end of file diff --git a/src/Network/Network/Az.Network.psd1 b/src/Network/Network/Az.Network.psd1 index 1b2519abaf77..fcc1290ff633 100644 --- a/src/Network/Network/Az.Network.psd1 +++ b/src/Network/Network/Az.Network.psd1 @@ -496,7 +496,10 @@ CmdletsToExport = 'Add-AzApplicationGatewayAuthenticationCertificate', 'New-AzVirtualApplianceSite', 'Remove-AzVirtualApplianceSite', 'Update-AzVirtualApplianceSite', 'New-AzOffice365PolicyProperty', 'Get-AzNetworkVirtualApplianceSku', - 'New-AzVirtualApplianceSkuProperty' + 'New-AzVirtualApplianceSkuProperty', + 'New-AzCustomIpPrefix', 'Update-AzCustomIpPrefix', + 'Get-AzCustomIpPrefix', 'Remove-AzCustomIpPrefix' + # Variables to export from this module # VariablesToExport = @() diff --git a/src/Network/Network/BYOIP/CustomIpPrefix/CustomIpPrefixBaseCmdlet.cs b/src/Network/Network/BYOIP/CustomIpPrefix/CustomIpPrefixBaseCmdlet.cs new file mode 100644 index 000000000000..d7566500d63b --- /dev/null +++ b/src/Network/Network/BYOIP/CustomIpPrefix/CustomIpPrefixBaseCmdlet.cs @@ -0,0 +1,52 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network +{ + using Microsoft.Azure.Commands.Network.Models; + using Microsoft.Azure.Commands.ResourceManager.Common.Tags; + using Microsoft.Azure.Management.Network; + using Microsoft.Azure.Management.Network.Models; + using System.Net; + + public abstract class CustomIpPrefixBaseCmdlet : NetworkBaseCmdlet + { + public ICustomIPPrefixesOperations CustomIpPrefixClient + { + get + { + return NetworkClient.NetworkManagementClient.CustomIPPrefixes; + } + } + + public PSCustomIpPrefix GetCustomIpPrefix(string resourceGroupName, string name, string expandResource = null) + { + var sdkModel = this.CustomIpPrefixClient.Get(resourceGroupName, name, expandResource); + + var psModel = ToPsCustomIpPrefix(sdkModel); + psModel.ResourceGroupName = resourceGroupName; + + return psModel; + } + + public PSCustomIpPrefix ToPsCustomIpPrefix(CustomIpPrefix customIpPrefix) + { + var psModel = NetworkResourceManagerProfile.Mapper.Map(customIpPrefix); + + psModel.Tag = TagsConversionHelper.CreateTagHashtable(customIpPrefix.Tags); + + return psModel; + } + } +} diff --git a/src/Network/Network/BYOIP/CustomIpPrefix/GetAzureCustomIpPrefixCommand.cs b/src/Network/Network/BYOIP/CustomIpPrefix/GetAzureCustomIpPrefixCommand.cs new file mode 100644 index 000000000000..9efaa748a400 --- /dev/null +++ b/src/Network/Network/BYOIP/CustomIpPrefix/GetAzureCustomIpPrefixCommand.cs @@ -0,0 +1,113 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network +{ + using Microsoft.Azure.Commands.Network.Models; + using Microsoft.Azure.Commands.ResourceManager.Common.Tags; + using Microsoft.Azure.Management.Network; + using System.Collections.Generic; + using System.Management.Automation; + using Microsoft.Azure.Management.Network.Models; + using Microsoft.Rest.Azure; + using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; + using Microsoft.WindowsAzure.Commands.Utilities.Common; + using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; + + [Cmdlet(VerbsCommon.Get, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "CustomIpPrefix", DefaultParameterSetName = GetByNameParameterSet), OutputType(typeof(PSCustomIpPrefix))] + public class GetAzureCustomIpPrefixCommand : CustomIpPrefixBaseCmdlet + { + private const string GetByNameParameterSet = "GetByNameParameterSet"; + private const string GetByResourceIdParameterSet = "GetByResourceIdParameterSet"; + + [Alias("ResourceName")] + [Parameter( + Mandatory = false, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The resource name.", + ParameterSetName = GetByNameParameterSet)] + [ResourceNameCompleter("Microsoft.Network/customIpPrefix", "ResourceGroupName")] + [ValidateNotNullOrEmpty] + [SupportsWildcards] + public virtual string Name { get; set; } + + [Parameter( + Mandatory = false, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The resource group name.", + ParameterSetName = GetByNameParameterSet)] + [ResourceGroupCompleter] + [ValidateNotNullOrEmpty] + [SupportsWildcards] + public virtual string ResourceGroupName { get; set; } + + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The resource id.", + ParameterSetName = GetByResourceIdParameterSet)] + [ValidateNotNullOrEmpty] + public virtual string ResourceId { get; set; } + + public override void Execute() + { + base.Execute(); + + if (this.IsParameterBound(c => c.ResourceId)) + { + var resourceIdentifier = new ResourceIdentifier(this.ResourceId); + this.ResourceGroupName = resourceIdentifier.ResourceGroupName; + this.Name = resourceIdentifier.ResourceName; + } + + if (ShouldGetByName(this.ResourceGroupName, this.Name)) + { + PSCustomIpPrefix psModel; + + psModel = this.GetCustomIpPrefix(this.ResourceGroupName, this.Name); + + WriteObject(psModel); + } + else + { + IPage page; + if (ShouldListByResourceGroup(this.ResourceGroupName, this.Name)) + { + page = this.CustomIpPrefixClient.List(this.ResourceGroupName); + } + else + { + page = this.CustomIpPrefixClient.ListAll(); + } + + // Get all resources by polling on next page link + List sdkModelList; + + sdkModelList = ListNextLink.GetAllResourcesByPollingNextLink(page, this.CustomIpPrefixClient.ListNext); + + var psModelList = new List(); + + // populate the publicIpPrefixes with the ResourceGroupName + foreach (var sdkModel in sdkModelList) + { + var psModel = this.ToPsCustomIpPrefix(sdkModel); + psModel.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(psModel.Id); + psModelList.Add(psModel); + } + + WriteObject(TopLevelWildcardFilter(this.ResourceGroupName, this.Name, psModelList), true); + } + } + } +} diff --git a/src/Network/Network/BYOIP/CustomIpPrefix/NewAzureCustomIpPrefixCommand.cs b/src/Network/Network/BYOIP/CustomIpPrefix/NewAzureCustomIpPrefixCommand.cs new file mode 100644 index 000000000000..63afddc7253a --- /dev/null +++ b/src/Network/Network/BYOIP/CustomIpPrefix/NewAzureCustomIpPrefixCommand.cs @@ -0,0 +1,119 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network +{ + using Microsoft.Azure.Commands.Network.Models; + using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; + using Microsoft.Azure.Commands.ResourceManager.Common.Tags; + using Microsoft.Azure.Management.Network; + using System.Collections; + using System.Linq; + using System.Management.Automation; + using MNM = Microsoft.Azure.Management.Network.Models; + + [Cmdlet(VerbsCommon.New, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "CustomIpPrefix", SupportsShouldProcess = true), OutputType(typeof(PSCustomIpPrefix))] + public class NewAzureCustomIpPrefixCommand : CustomIpPrefixBaseCmdlet + { + [Alias("ResourceName")] + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The resource name.")] + [ValidateNotNullOrEmpty] + public virtual string Name { get; set; } + + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The resource group name.")] + [ResourceGroupCompleter] + [ValidateNotNullOrEmpty] + public virtual string ResourceGroupName { get; set; } + + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The customIpPrefix location.")] + [LocationCompleter("Microsoft.Network/customIpPrefix")] + [ValidateNotNullOrEmpty] + public string Location { get; set; } + + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The customIpPrefix CIDR.")] + [ValidateNotNullOrEmpty] + public string Cidr { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "A list of availability zones denoting the IP allocated for the resource needs to come from.", + ValueFromPipelineByPropertyName = true)] + public string[] Zone { get; set; } + + [Parameter( + Mandatory = false, + ValueFromPipelineByPropertyName = true, + HelpMessage = "A hashtable which represents resource tags.")] + public Hashtable Tag { get; set; } + + [Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] + public SwitchParameter AsJob { get; set; } + + public override void Execute() + { + base.Execute(); + var resourceExists = IsResourcePresent(() => GetCustomIpPrefix(this.ResourceGroupName, this.Name)); + + if (resourceExists) + { + throw new System.Exception(string.Format("A CustomIpPrefix with name '{0}' in resource group '{1}' already exists. Please use Set-AzCustomIpPrefix to update an existing CustomIpPrefix.", this.Name, this.ResourceGroupName)); + } + + var psModel = CreateCustomIpPrefix(); + if (psModel != null) + { + WriteObject(psModel); + } + } + + private PSCustomIpPrefix CreateCustomIpPrefix() + { + var psModel = new PSCustomIpPrefix() + { + Name = this.Name, + ResourceGroupName = this.ResourceGroupName, + Location = this.Location, + Cidr = this.Cidr, + Zones = this.Zone?.ToList() + }; + + var sdkModel = NetworkResourceManagerProfile.Mapper.Map(psModel); + + sdkModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true); + + if (this.ShouldProcess($"Name: {this.Name} ResourceGroup: {this.ResourceGroupName}", "Create new MasterCustomIpPrefix")) + { + this.CustomIpPrefixClient.CreateOrUpdate(this.ResourceGroupName, this.Name, sdkModel); + + var customIpPrefix = this.GetCustomIpPrefix(this.ResourceGroupName, this.Name); + + return customIpPrefix; + } + + return null; + } + } +} \ No newline at end of file diff --git a/src/Network/Network/BYOIP/CustomIpPrefix/RemoveAzureCustomIpPrefixCommand.cs b/src/Network/Network/BYOIP/CustomIpPrefix/RemoveAzureCustomIpPrefixCommand.cs new file mode 100644 index 000000000000..e2d522db9b9f --- /dev/null +++ b/src/Network/Network/BYOIP/CustomIpPrefix/RemoveAzureCustomIpPrefixCommand.cs @@ -0,0 +1,112 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network +{ + using Microsoft.Azure.Commands.Network.Models; + using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; + using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; + using Microsoft.Azure.Management.Network; + using Microsoft.WindowsAzure.Commands.Utilities.Common; + using System.Management.Automation; + + [Cmdlet(VerbsCommon.Remove, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "CustomIpPrefix", SupportsShouldProcess = true, DefaultParameterSetName = DeleteByNameParameterSet), OutputType(typeof(bool))] + public class RemoveAzureCustomIpPrefixCommand : CustomIpPrefixBaseCmdlet + { + private const string DeleteByNameParameterSet = "DeleteByNameParameterSet"; + private const string DeleteByInputObjectParameterSet = "DeleteByInputObjectParameterSet"; + private const string DeleteByResourceIdParameterSet = "DeleteByResourceIdParameterSet"; + + [Alias("ResourceName")] + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The resource name.", + ParameterSetName = DeleteByNameParameterSet)] + [ResourceNameCompleter("Microsoft.Network/customIpPrefix", "ResourceGroupName")] + [ValidateNotNullOrEmpty] + public virtual string Name { get; set; } + + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The resource group name.", + ParameterSetName = DeleteByNameParameterSet)] + [ResourceGroupCompleter] + [ValidateNotNullOrEmpty] + public virtual string ResourceGroupName { get; set; } + + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The resource id.", + ParameterSetName = DeleteByResourceIdParameterSet)] + [ValidateNotNullOrEmpty] + public virtual string ResourceId { get; set; } + + [Parameter( + Mandatory = true, + ValueFromPipeline = true, + HelpMessage = "A customIpPrefix object.", + ParameterSetName = DeleteByInputObjectParameterSet)] + [ValidateNotNull] + public PSCustomIpPrefix InputObject { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "Do not ask for confirmation.")] + public SwitchParameter Force { get; set; } + + [Parameter(Mandatory = false)] + public SwitchParameter PassThru { get; set; } + + [Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] + public SwitchParameter AsJob { get; set; } + + public override void Execute() + { + base.Execute(); + + if (this.IsParameterBound(c => c.InputObject)) + { + this.ResourceGroupName = this.InputObject.ResourceGroupName; + this.Name = this.InputObject.Name; + } + + if (this.IsParameterBound(c => c.ResourceId)) + { + var resourceIdentifier = new ResourceIdentifier(this.ResourceId); + this.ResourceGroupName = resourceIdentifier.ResourceGroupName; + this.Name = resourceIdentifier.ResourceName; + } + + ConfirmAction( + Force.IsPresent, + string.Format(Microsoft.Azure.Commands.Network.Properties.Resources.RemovingResource, Name), + Microsoft.Azure.Commands.Network.Properties.Resources.RemoveResourceMessage, + Name, + () => + { + if (this.ShouldProcess(this.Name, $"Deleting CustomIpPrefix: {this.Name} in ResourceGroup: {this.ResourceGroupName}")) + { + this.CustomIpPrefixClient.Delete(this.ResourceGroupName, this.Name); + if (PassThru) + { + WriteObject(true); + } + } + }); + } + } +} diff --git a/src/Network/Network/BYOIP/CustomIpPrefix/UpdateAzureCustomIpPrefixCommand.cs b/src/Network/Network/BYOIP/CustomIpPrefix/UpdateAzureCustomIpPrefixCommand.cs new file mode 100644 index 000000000000..a69b15d86a84 --- /dev/null +++ b/src/Network/Network/BYOIP/CustomIpPrefix/UpdateAzureCustomIpPrefixCommand.cs @@ -0,0 +1,145 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network +{ + using Microsoft.Azure.Commands.Network.Models; + using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; + using Microsoft.Azure.Commands.ResourceManager.Common.Tags; + using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; + using Microsoft.Azure.Management.Network; + using Microsoft.WindowsAzure.Commands.Utilities.Common; + using System; + using System.Collections; + using System.Management.Automation; + using MNM = Microsoft.Azure.Management.Network.Models; + + [Cmdlet(VerbsData.Update, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "CustomIpPrefix", SupportsShouldProcess = true, DefaultParameterSetName = UpdateByNameParameterSet), OutputType(typeof(PSCustomIpPrefix))] + public class UpdateAzureCustomIpPrefixCommand : CustomIpPrefixBaseCmdlet + { + private const string UpdateByNameParameterSet = "UpdateByNameParameterSet"; + private const string UpdateByInputObjectParameterSet = "UpdateByInputObjectParameterSet"; + private const string UpdateByResourceIdParameterSet = "UpdateByResourceIdParameterSet"; + + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The resource name.", ParameterSetName = UpdateByNameParameterSet)] + [ResourceNameCompleter("Microsoft.Network/customIpPrefix", "ResourceGroupName")] + [ValidateNotNullOrEmpty] + [SupportsWildcards] + public virtual string Name { get; set; } + + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The resource group name.", ParameterSetName = UpdateByNameParameterSet)] + [ValidateNotNullOrEmpty] + [SupportsWildcards] + public virtual string ResourceGroupName { get; set; } + + [Parameter( + Mandatory = true, + ValueFromPipeline = true, + HelpMessage = "The CustomIpPrefix to set.", ParameterSetName = UpdateByInputObjectParameterSet)] + public PSCustomIpPrefix InputObject { get; set; } + + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The resource Id.", ParameterSetName = UpdateByResourceIdParameterSet)] + [ValidateNotNullOrEmpty] + [SupportsWildcards] + public virtual string ResourceId { get; set; } + + [Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] + public SwitchParameter Commission { get; set; } + + [Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] + public SwitchParameter Decomission { get; set; } + + [Parameter( + Mandatory = false, + ValueFromPipelineByPropertyName = true, + HelpMessage = "A hashtable which represents resource tags.", + ParameterSetName = UpdateByNameParameterSet)] + [Parameter(Mandatory = false, ParameterSetName = UpdateByResourceIdParameterSet)] + [Parameter(Mandatory = false, ParameterSetName = UpdateByInputObjectParameterSet)] + public Hashtable Tag { get; set; } + + [Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] + public SwitchParameter AsJob { get; set; } + + public override void Execute() + { + base.Execute(); + + if (this.IsParameterBound(c => c.ResourceId)) + { + var resourceInfo = new ResourceIdentifier(ResourceId); + this.ResourceGroupName = resourceInfo.ResourceGroupName; + this.Name = resourceInfo.ResourceName; + } + else if (this.IsParameterBound(c => c.InputObject)) + { + this.ResourceGroupName = InputObject.ResourceGroupName; + this.Name = InputObject.Name; + } + + var existingResourcePsModel = GetCustomIpPrefix(this.ResourceGroupName, this.Name); + if (existingResourcePsModel == null) + { + throw new ArgumentException(Microsoft.Azure.Commands.Network.Properties.Resources.ResourceNotFound); + } + + if (Commission && Decomission) + { + throw new ArgumentException(Microsoft.Azure.Commands.Network.Properties.Resources.CommissioningStateConflict); + } + + PSCustomIpPrefix customIpPrefixToUpdate = this.GetCustomIpPrefix(this.ResourceGroupName, this.Name); + + if (customIpPrefixToUpdate == null) + { + throw new PSArgumentException(Properties.Resources.ResourceNotFound, this.Name); + } + + if (Commission || Decomission) + { + customIpPrefixToUpdate.CommissionedState = Commission ? "Commissioning" : "Decomissioning"; + } + + var sdkModel = NetworkResourceManagerProfile.Mapper.Map(customIpPrefixToUpdate); + + if (this.IsParameterBound(c => c.InputObject)) + { + sdkModel.Tags = TagsConversionHelper.CreateTagDictionary(this.IsParameterBound(c => c.Tag) ? this.Tag : InputObject.Tag, validate: true); + } + else + { + sdkModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true); + } + + if (this.ShouldProcess($"Name: {this.Name} ResourceGroup: {this.ResourceGroupName}", "Update existing CustomIpPrefix")) + { + // Execute the PUT MasterCustomIpPrefix Policy call + this.CustomIpPrefixClient.CreateOrUpdate(this.ResourceGroupName, this.Name, sdkModel); + + var customIpPrefix = this.GetCustomIpPrefix(this.ResourceGroupName, this.Name); + + WriteObject(customIpPrefix); + } + } + } +} diff --git a/src/Network/Network/Common/NetworkResourceManagerProfile.cs b/src/Network/Network/Common/NetworkResourceManagerProfile.cs index 8b3db64da9a2..937f397acf37 100644 --- a/src/Network/Network/Common/NetworkResourceManagerProfile.cs +++ b/src/Network/Network/Common/NetworkResourceManagerProfile.cs @@ -394,6 +394,13 @@ private static void Initialize() cfg.CreateMap(); cfg.CreateMap(); + // CustomIpPrefix + // CNM to MNM + cfg.CreateMap(); + + // MNM to CNM + cfg.CreateMap(); + // NetworkInterface // CNM to MNM cfg.CreateMap(); diff --git a/src/Network/Network/Models/BYOIP/PSCustomIpPrefix.cs b/src/Network/Network/Models/BYOIP/PSCustomIpPrefix.cs new file mode 100644 index 000000000000..2a21f05cc322 --- /dev/null +++ b/src/Network/Network/Models/BYOIP/PSCustomIpPrefix.cs @@ -0,0 +1,38 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network.Models +{ + using Newtonsoft.Json; + using System.Collections.Generic; + + public class PSCustomIpPrefix : PSTopLevelResource + { + public string Cidr { get; set; } + + public string CommissionedState { get; set; } + + public List PublicIpPrefixes { get; set; } + + public List Zones { get; set; } + + public string ProvisioningState { get; set; } + + [JsonIgnore] + public string PublicIpPrefixesText + { + get { return JsonConvert.SerializeObject(PublicIpPrefixes, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); } + } + } +} diff --git a/src/Network/Network/Models/PSPublicIpPrefix.cs b/src/Network/Network/Models/PSPublicIpPrefix.cs index 03d6e14fffa7..d85c109fb5b4 100644 --- a/src/Network/Network/Models/PSPublicIpPrefix.cs +++ b/src/Network/Network/Models/PSPublicIpPrefix.cs @@ -35,6 +35,8 @@ public class PSPublicIpPrefix : PSTopLevelResource public List PublicIpAddresses { get; set; } + public PSResourceId CustomIpPrefix { get; set; } + [JsonIgnore] public string PublicIpAddressesText { diff --git a/src/Network/Network/Network.csproj b/src/Network/Network/Network.csproj index c4bf14045c75..6be8b37c7aff 100644 --- a/src/Network/Network/Network.csproj +++ b/src/Network/Network/Network.csproj @@ -40,4 +40,4 @@ - + \ No newline at end of file diff --git a/src/Network/Network/Network.format.ps1xml b/src/Network/Network/Network.format.ps1xml index 1b4e14954873..7b7d01d8bc8c 100644 --- a/src/Network/Network/Network.format.ps1xml +++ b/src/Network/Network/Network.format.ps1xml @@ -1492,6 +1492,68 @@ + + + Microsoft.Azure.Commands.Network.Models.PSCustomIpPrefix + + Microsoft.Azure.Commands.Network.Models.PSCustomIpPrefix + + + + + + + + Name + + + + ResourceGroupName + + + + Location + + + + Id + + + + Etag + + + + ResourceGuid + + + + ProvisioningState + + + + TagsTable + + + + Cidr + + + + CommissionedState + + + + PublicIpPrefixesText + + + + Zones + + + + + Microsoft.Azure.Commands.Network.Models.PSPublicIpPrefix diff --git a/src/Network/Network/Properties/Resources.Designer.cs b/src/Network/Network/Properties/Resources.Designer.cs index 80d069c1b285..b68f61a384c4 100644 --- a/src/Network/Network/Properties/Resources.Designer.cs +++ b/src/Network/Network/Properties/Resources.Designer.cs @@ -267,6 +267,15 @@ internal static string ChildResourceAlreadyPresentInResourceGroup { } } + /// + /// Looks up a localized string similar to Cannot have both 'Commission' and 'Decomission' flags set. + /// + internal static string CommissioningStateConflict { + get { + return ResourceManager.GetString("CommissioningStateConflict", resourceCulture); + } + } + /// /// Looks up a localized string similar to Connection monitor test group contains duplicates in destination endpoint names. Destination endpoint names in testGroup must be unique.. /// diff --git a/src/Network/Network/Properties/Resources.resx b/src/Network/Network/Properties/Resources.resx index 36e06c980d34..bd9e39a440a1 100644 --- a/src/Network/Network/Properties/Resources.resx +++ b/src/Network/Network/Properties/Resources.resx @@ -692,4 +692,8 @@ A valid HubRouteTable reference is required. + + Cannot have both 'Commission' and 'Decomission' flags set + Error message for setting the customIpPrefix + \ No newline at end of file diff --git a/src/Network/Network/PublicIpPrefix/NewAzurePublicIpPrefixCommand.cs b/src/Network/Network/PublicIpPrefix/NewAzurePublicIpPrefixCommand.cs index bc83345ef07f..5f73b783961d 100644 --- a/src/Network/Network/PublicIpPrefix/NewAzurePublicIpPrefixCommand.cs +++ b/src/Network/Network/PublicIpPrefix/NewAzurePublicIpPrefixCommand.cs @@ -96,6 +96,12 @@ public class NewAzurePublicIpPrefixCommand : PublicIpPrefixBaseCmdlet ValueFromPipelineByPropertyName = true)] public string[] Zone { get; set; } + [Parameter( + Mandatory = false, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The CustomIpPrefix that this PublicIpPrefix will be associated with")] + public PSCustomIpPrefix CustomIpPrefix { get; set; } + [Parameter( Mandatory = false, ValueFromPipelineByPropertyName = true, @@ -165,6 +171,8 @@ private PSPublicIpPrefix CreatePublicIpPrefix() publicIpPrefix.IpTags = this.IpTag?.ToList(); } + publicIpPrefix.CustomIpPrefix = this.CustomIpPrefix; + var theModel = NetworkResourceManagerProfile.Mapper.Map(publicIpPrefix); theModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true); diff --git a/src/Network/Network/help/Get-AzCustomIpPrefix.md b/src/Network/Network/help/Get-AzCustomIpPrefix.md new file mode 100644 index 000000000000..eeddad27a690 --- /dev/null +++ b/src/Network/Network/help/Get-AzCustomIpPrefix.md @@ -0,0 +1,133 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Network.dll-Help.xml +Module Name: Az.Network +online version: https://docs.microsoft.com/en-us/powershell/module/az.network/get-azcustomipprefix +schema: 2.0.0 +--- + +# Get-AzCustomIpPrefix + +## SYNOPSIS +Gets a CustomIpPrefix resource + +## SYNTAX + +### GetByNameParameterSet (Default) +``` +Get-AzCustomIpPrefix [-Name ] [-ResourceGroupName ] [-DefaultProfile ] + [] +``` + +### GetByResourceIdParameterSet +``` +Get-AzCustomIpPrefix -ResourceId [-DefaultProfile ] [] +``` + +## DESCRIPTION +The **Get-AzCustomIpPrefix** cmdlet gets one or more CustomIpPrefixes given the set of input parameters + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-AzPublicIpPrefix -ResourceGroupName myRg -Name myCustomIpPrefix + +Name : myCustomIpPrefix +ResourceGroupName : myRg +Location : westus +Id : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/byoip-test-rg/providers/Micro + soft.Network/customIPPrefixes/testCustomIpPrefix +Etag : W/"00000000-0000-0000-0000-000000000000" +ResourceGuid : 00000000-0000-0000-0000-000000000000 +ProvisioningState : Succeeded +Tags : +Cidr : 111.111.111.111/24 +CommissionedState : Provisioning +PublicIpPrefixes : [] +Zones : {} +``` + +This command gets a CustomIpPrefix resource named myCustomIpPrefix in resource group myRg + +## PARAMETERS + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +The resource name. + +```yaml +Type: String +Parameter Sets: GetByNameParameterSet +Aliases: ResourceName + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ResourceGroupName +The resource group name. + +```yaml +Type: String +Parameter Sets: GetByNameParameterSet +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ResourceId +The resource id. + +```yaml +Type: String +Parameter Sets: GetByResourceIdParameterSet +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String + +## OUTPUTS + +### Microsoft.Azure.Commands.Network.Models.PSCustomIpPrefix + +## NOTES + +## RELATED LINKS + +[New-AzCustomIpPrefix](./New-AzCustomIpPrefix.md) + +[Remove-AzCustomIpPrefix](./Remove-AzCustomIpPrefix.md) + +[Update-AzCustomIpPrefix](./Update-AzCustomIpPrefix.md) \ No newline at end of file diff --git a/src/Network/Network/help/New-AzCustomIpPrefix.md b/src/Network/Network/help/New-AzCustomIpPrefix.md new file mode 100644 index 000000000000..66bb3d91032c --- /dev/null +++ b/src/Network/Network/help/New-AzCustomIpPrefix.md @@ -0,0 +1,209 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Network.dll-Help.xml +Module Name: Az.Network +online version: https://docs.microsoft.com/en-us/powershell/module/az.network/new-azcustomipprefix +schema: 2.0.0 +--- + +# New-AzCustomIpPrefix + +## SYNOPSIS +Creates a CustomIpPrefix resource + +## SYNTAX + +``` +New-AzCustomIpPrefix -Name -ResourceGroupName -Location -Cidr + [-Zone ] [-Tag ] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +The **New-AzCustomIpPrefix** cmdlet creates a CustomIpPrefix resource. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> $myCustomIpPrefix = New-AzCustomIpPrefix -Name $prefixName -ResourceGroupName $rgName -Cidr 40.40.40.0/24 -Location westus +``` + +This command creates a new CustomIpPrefix resource with name $prefixName in resource group $rgName with a cidr of 40.40.40.0/24 in westus + +## PARAMETERS + +### -AsJob +Run cmdlet in the background + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Cidr +The CustomIpPrefix CIDR. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Location +The CustomIpPrefix location. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +The resource name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: ResourceName + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ResourceGroupName +The resource group name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Tag +A hashtable which represents resource tags. + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Zone +A list of availability zones denoting the IP allocated for the resource needs to come from. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String + +### System.String[] + +### System.Collections.Hashtable + +## OUTPUTS + +### Microsoft.Azure.Commands.Network.Models.PSCustomIpPrefix + +## NOTES + +## RELATED LINKS + +[Get-AzCustomIpPrefix](./Get-AzCustomIpPrefix.md) + +[Remove-AzCustomIpPrefix](./Remove-AzCustomIpPrefix.md) + +[Update-AzCustomIpPrefix](./Update-AzCustomIpPrefix.md) \ No newline at end of file diff --git a/src/Network/Network/help/Remove-AzCustomIpPrefix.md b/src/Network/Network/help/Remove-AzCustomIpPrefix.md new file mode 100644 index 000000000000..d99134751767 --- /dev/null +++ b/src/Network/Network/help/Remove-AzCustomIpPrefix.md @@ -0,0 +1,220 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Network.dll-Help.xml +Module Name: Az.Network +online version: https://docs.microsoft.com/en-us/powershell/module/az.network/remove-azcustomipprefix +schema: 2.0.0 +--- + +# Remove-AzCustomIpPrefix + +## SYNOPSIS +Removes a CustomIpPrefix + +## SYNTAX + +### DeleteByNameParameterSet (Default) +``` +Remove-AzCustomIpPrefix -Name -ResourceGroupName [-Force] [-PassThru] [-AsJob] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +### DeleteByResourceIdParameterSet +``` +Remove-AzCustomIpPrefix -ResourceId [-Force] [-PassThru] [-AsJob] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +### DeleteByInputObjectParameterSet +``` +Remove-AzCustomIpPrefix -InputObject [-Force] [-PassThru] [-AsJob] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +The **Remove-AzCustomIpPrefix** cmdlet removes a CustomIpPrefix. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Remove-AzCustomIpPrefix -Name $prefixName -ResourceGroupName $rgName +``` + +Removes the CustomIpPrefix with Name $prefixName from resource group $rgName + +## PARAMETERS + +### -AsJob +Run cmdlet in the background + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Force +Do not ask for confirmation. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InputObject +A customIpPrefix object. + +```yaml +Type: PSCustomIpPrefix +Parameter Sets: DeleteByInputObjectParameterSet +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -Name +The resource name. + +```yaml +Type: String +Parameter Sets: DeleteByNameParameterSet +Aliases: ResourceName + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -PassThru +Returns an object representing the item with which you are working. +By default, this cmdlet does not generate any output. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ResourceGroupName +The resource group name. + +```yaml +Type: String +Parameter Sets: DeleteByNameParameterSet +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ResourceId +The resource id. + +```yaml +Type: String +Parameter Sets: DeleteByResourceIdParameterSet +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String + +### Microsoft.Azure.Commands.Network.Models.PSCustomIpPrefix + +## OUTPUTS + +### System.Boolean + +## NOTES + +## RELATED LINKS + +[Get-AzCustomIpPrefix](./Get-AzCustomIpPrefix.md) + +[New-AzCustomIpPrefix](./New-AzCustomIpPrefix.md) + +[Update-AzCustomIpPrefix](./Update-AzCustomIpPrefix.md) \ No newline at end of file diff --git a/src/Network/Network/help/Update-AzCustomIpPrefix.md b/src/Network/Network/help/Update-AzCustomIpPrefix.md new file mode 100644 index 000000000000..a37b5cf8901d --- /dev/null +++ b/src/Network/Network/help/Update-AzCustomIpPrefix.md @@ -0,0 +1,263 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Network.dll-Help.xml +Module Name: Az.Network +online version: https://docs.microsoft.com/en-us/powershell/module/az.network/update-azcustomipprefix +schema: 2.0.0 +--- + +# Update-AzCustomIpPrefix + +## SYNOPSIS +Updates a CustomIpPrefix + +## SYNTAX + +### UpdateByNameParameterSet +``` +Update-AzCustomIpPrefix -Name -ResourceGroupName [-Commission] [-Decomission] + [-Tag ] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] + [] +``` + +### UpdateByInputObjectParameterSet +``` +Update-AzCustomIpPrefix -InputObject [-Commission] [-Decomission] [-Tag ] + [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +### UpdateByResourceIdParameterSet +``` +Update-AzCustomIpPrefix -ResourceId [-Commission] [-Decomission] [-Tag ] [-AsJob] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +The **Update-AzCustomIpPrefix** cmdlet allows the user to either commission or decommission their CustomIpPrefix, or edit the tags of the resource. + +## EXAMPLES + +### Example 1 : Commission the CustomIpPrefix +```powershell +PS C:\> Update-AzCustomIpPrefix -Name $prefixName -ResourceGroupName $rgName -Commission +``` + +The above command will start the commissioning process of the CustomIpPrefix. + +### Example 2 : Decommission the CustomIpPrefix +```powershell +PS C:\> Update-AzCustomIpPrefix -Name $prefixName -ResourceGroupName $rgName -Decommission +``` + +The above command will start the de-commissioning process of the CustomIpPrefix. + +### Example 3 : Update tags for the CustomIpPrefix +```powershell +PS C:\> Update-AzCustomIpPrefix -Name $prefixName -ResourceGroupName $rgName -Tag $tags +``` + +The above command will update the tags for the CustomIpPrefix. + +## PARAMETERS + +### -AsJob +Run cmdlet in the background + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Commission +Run cmdlet in the background + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Decomission +Run cmdlet in the background + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InputObject +The CustomIpPrefix to set. + +```yaml +Type: PSCustomIpPrefix +Parameter Sets: SetByInputObjectParameterSet +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -Name +The resource name. + +```yaml +Type: String +Parameter Sets: SetByNameParameterSet +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ResourceGroupName +The resource group name. + +```yaml +Type: String +Parameter Sets: SetByNameParameterSet +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ResourceId +The resource Id. + +```yaml +Type: String +Parameter Sets: SetByResourceIdParameterSet +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Tag +A hashtable which represents resource tags. + +```yaml +Type: Hashtable +Parameter Sets: SetByNameParameterSet +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +```yaml +Type: Hashtable +Parameter Sets: SetByInputObjectParameterSet, SetByResourceIdParameterSet +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String + +### Microsoft.Azure.Commands.Network.Models.PSCustomIpPrefix + +### System.Collections.Hashtable + +## OUTPUTS + +### Microsoft.Azure.Commands.Network.Models.PSCustomIpPrefix + +## NOTES + +## RELATED LINKS + +[Get-AzCustomIpPrefix](./Get-AzCustomIpPrefix.md) + +[New-AzCustomIpPrefix](./New-AzCustomIpPrefix.md) + +[Remove-AzCustomIpPrefix](./Remove-AzCustomIpPrefix.md) \ No newline at end of file