Skip to content

Add dns name public ip #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Common/Commands.Common.Test/Commands.Common.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@
<Reference Include="Microsoft.WindowsAzure.Management">
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.2.1\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Compute.11.2.1\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.1.1\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Commands.Common.Test/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="9.2.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="11.2.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.1.1" targetFramework="net45" />
<package id="Moq" version="4.2.1402.2112" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
Expand Down
25 changes: 25 additions & 0 deletions src/Common/Commands.Common/ServiceManagementTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,8 @@ public class AssignPublicIP
[DataMember(Name = "IdleTimeoutInMinutes", EmitDefaultValue = false, Order = 2)]
public int? IdleTimeoutInMinutes { get; set; }

[DataMember(Name = "DomainNameLabel", EmitDefaultValue = false, Order = 3)]
public string DomainNameLabel { get; set; }
}

[CollectionDataContract(Name = "NetworkInterfaces", ItemName = "NetworkInterface", Namespace = Constants.ServiceManagementNS)]
Expand Down Expand Up @@ -3075,9 +3077,32 @@ public class PublicIP : IExtensibleDataObject
[DataMember(EmitDefaultValue = false, Order = 2)]
public string Address { get; set; }

[DataMember(EmitDefaultValue = false, Order = 3)]
public int? IdleTimeoutInMinutes { get; set; }

[DataMember(EmitDefaultValue = false, Order = 4)]
public string DomainNameLabel { get; set; }

[DataMember(EmitDefaultValue = false, Order = 5)]
public FqdnsList Fqdns { get; set; }

public ExtensionDataObject ExtensionData { get; set; }
}

[CollectionDataContract(Name = "Fqdns", ItemName = "Fqdn", Namespace = Constants.ServiceManagementNS)]
public class FqdnsList : List<string>
{
public FqdnsList()
{

}

public FqdnsList(IEnumerable<string> fqdns)
: base(fqdns)
{

}
}

[CollectionDataContract(Name = "LoadBalancers", ItemName = "LoadBalancer", Namespace = Constants.ServiceManagementNS)]
public class LoadBalancerList : List<LoadBalancer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.2.1\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Compute.11.2.1\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.1.1\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Commands.ScenarioTest/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="9.2.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="11.2.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.WebSites" version="4.4.2-prerelease" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@
<Reference Include="Microsoft.WindowsAzure.Management">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.2.1\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=11.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.11.2.1\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.12.111071459" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="9.2.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="11.2.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@
<Reference Include="Microsoft.WindowsAzure.Management">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.2.1\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=11.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.11.2.1\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.1.1\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="9.2.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="11.2.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.1.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
<package id="System.Spatial" version="5.6.0" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.2.1\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.11.2.1\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="9.2.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="11.2.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Network" version="6.1.2" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.1.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@
<Reference Include="Microsoft.WindowsAzure.Management">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.2.1\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=11.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.11.2.1\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests
{
public class SetAzurePublicIPCmdletInfo: CmdletsInfo
{

public SetAzurePublicIPCmdletInfo(string publicIPName,IPersistentVM vm)
public SetAzurePublicIPCmdletInfo(string publicIPName, IPersistentVM vm, string domainNameLabel = null)
{
this.cmdletName = Utilities.SetAzurePublicIPCmdletName;
this.parameters.Add(new CmdletParam("PublicIPName", publicIPName));
if (!string.IsNullOrEmpty(domainNameLabel))
{
this.parameters.Add(new CmdletParam("DomainNameLabel", domainNameLabel));
}

this.parameters.Add(new CmdletParam("VM", vm));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,47 @@ public void PublicIpPerVMTest()
}
}

private static PersistentVM CreateVMWithEndpointDataDiskAndPublicIP(string vmName, string endpointName, string disklabel1, string publicIpName, string serviceName, int localPort, int publicport)

// The dns name on publicIP is currently in beta, remove Ignore flag once feature is in public
[Ignore]
[TestMethod(), Priority(0), TestProperty("Feature", "IaaS"), TestCategory(Category.Network), Owner("derajen"), Description("Test the Get/Set-AzurePublicIP cmdlets with domainNameLabel")]
public void PublicIpDomainNameLabelVMTest()
{
try
{
string vmname = Utilities.GetUniqueShortName(vmNamePrefix);
string endpointName = Utilities.GetUniqueShortName("endpoint");
string disklabel1 = Utilities.GetUniqueShortName("disk");
string publicIpName = Utilities.GetUniqueShortName("publicIp");
string publicIpDomainNameLabel = Utilities.GetUniqueShortName("publicIpdns");

vmPowershellCmdlets.NewAzureService(serviceName, locationName);
var vm = CreateVMWithEndpointDataDiskAndPublicIP(vmname, endpointName, disklabel1, publicIpName, serviceName, LOCAL_PORT_NUMBER1, PUBLIC_PORT_NUMBER1, publicIpDomainNameLabel);
vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm });

VerifyPublicIP(publicIpName, vm);

// Get azure VM
var virtualMachine = vmPowershellCmdlets.GetAzureVM(vmname, serviceName);
Assert.AreEqual(publicIpDomainNameLabel, virtualMachine.PublicIPDomainNameLabel);
Assert.AreEqual(string.Format("{0}.{1}.cloudapp.net", publicIpDomainNameLabel, serviceName), virtualMachine.PublicIPFqdns[0]);
Assert.AreEqual(string.Format("{0}.0.{1}.cloudapp.net", publicIpDomainNameLabel, serviceName), virtualMachine.PublicIPFqdns[1]);

pass = true;
}
catch (Exception ex)
{
pass = false;
Console.WriteLine(ex);
if (ex.InnerException != null)
{
Console.WriteLine(ex.InnerException);
}
throw ex;
}
}

private static PersistentVM CreateVMWithEndpointDataDiskAndPublicIP(string vmName, string endpointName, string disklabel1, string publicIpName, string serviceName, int localPort, int publicport, string publicIpDomainNameLabel = null)
{
var vm1 = Utilities.CreateIaaSVMObject(vmName, InstanceSize.Small, imageName, true, username, password);
var endpointConfiginput = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, TCP_PROTOCAL, localPort, publicport, endpointName, serviceName: serviceName);
Expand All @@ -318,7 +358,7 @@ private static PersistentVM CreateVMWithEndpointDataDiskAndPublicIP(string vmNam
var dataDiskConfig1 = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 128, disklabel1, 0);
dataDiskConfig1.Vm = vm1;
vm1 = vmPowershellCmdlets.AddAzureDataDisk(dataDiskConfig1);
vm1 = (PersistentVM)vmPowershellCmdlets.SetAzurePublicIp(publicIpName, vm1);
vm1 = (PersistentVM)vmPowershellCmdlets.SetAzurePublicIp(publicIpName, vm1, publicIpDomainNameLabel);
return vm1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2224,9 +2224,9 @@ internal SM.InternalLoadBalancerContext GetAzureInternalLoadBalancer(string serv
return RunPSCmdletAndReturnFirst<SM.InternalLoadBalancerContext>(new GetAzureInternalLoadBalancerCmdletInfo(serviceName));
}

internal SM.IPersistentVM SetAzurePublicIp(string publicIpName, SM.IPersistentVM vm)
internal SM.IPersistentVM SetAzurePublicIp(string publicIpName, SM.IPersistentVM vm, string domainNameLabel = null)
{
return RunPSCmdletAndReturnFirst<SM.IPersistentVM>(new SetAzurePublicIPCmdletInfo(publicIpName, vm));
return RunPSCmdletAndReturnFirst<SM.IPersistentVM>(new SetAzurePublicIPCmdletInfo(publicIpName, vm, domainNameLabel));
}

internal SM.AssignPublicIP GetAzurePublicIpName(string publicIpName, SM.IPersistentVM vm)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="9.2.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="11.2.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Network" version="6.1.2" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.1.1" targetFramework="net45" />
<package id="Moq" version="4.2.1402.2112" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@
<Reference Include="Microsoft.WindowsAzure.Management">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.2.1\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=11.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.11.2.1\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public void GetRoleProcess()
: PersistentVMHelper.GetPublicIPName(vmRole),
PublicIPIdleTimeoutInMinutes = role.PublicIPs == null || !role.PublicIPs.Any() ? null
: role.PublicIPs.First().IdleTimeoutInMinutes,
PublicIPDomainNameLabel = role.PublicIPs == null || !role.PublicIPs.Any() ? null : role.PublicIPs.First().DomainNameLabel,
PublicIPFqdns = role.PublicIPs == null || !role.PublicIPs.Any() ? null : role.PublicIPs.First().Fqdns.ToList(),
DeploymentID = currentDeployment.PrivateId,
InstanceEndpoints = Mapper.Map<PVM.InstanceEndpointList>(role.InstanceEndpoints)
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public class SetAzurePublicIPCommand : VirtualMachineConfigurationCmdletBase
[ValidateNotNullOrEmpty]
public int? IdleTimeoutInMinutes { get; set; }

[Parameter(Position = 3, Mandatory = false, HelpMessage = "DNS name.")]
[ValidateNotNullOrEmpty]
public string DomainNameLabel { get; set; }

protected override void ProcessRecord()
{
base.ProcessRecord();
Expand All @@ -53,6 +57,15 @@ protected override void ProcessRecord()
{
networkConfiguration.PublicIPs.First().IdleTimeoutInMinutes = this.IdleTimeoutInMinutes;
}

if (this.ParameterSpecified("DomainNameLabel"))
{
networkConfiguration.PublicIPs.First().DomainNameLabel = this.DomainNameLabel;
}
else
{
networkConfiguration.PublicIPs.First().DomainNameLabel = null;
}
}
else
{
Expand All @@ -61,6 +74,7 @@ protected override void ProcessRecord()
{
Name = this.PublicIPName,
IdleTimeoutInMinutes = this.ParameterSpecified("IdleTimeoutInMinutes") ? this.IdleTimeoutInMinutes : null,
DomainNameLabel = this.ParameterSpecified("DomainNameLabel") ? this.DomainNameLabel : null,
});
}

Expand Down
Loading