Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/ResourceManager/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Current Release
* `New-AzureRmVMSS` prints connection strings in verbose mode.
* `New-AzureRmVmss` supports public IP address, load balancing rules, inbound NAT rules.
* WriteAccelerator feature
- Added WriteAccelerator switch parameter to the following cmdlets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using Microsoft.Azure.Commands.Common.Strategies;
using Microsoft.Azure.Commands.Compute.Automation.Models;
using Microsoft.Azure.Commands.Compute.Properties;
using Microsoft.Azure.Commands.Compute.Strategies;
using Microsoft.Azure.Commands.Compute.Strategies.ComputeRp;
using Microsoft.Azure.Commands.Compute.Strategies.Network;
Expand Down Expand Up @@ -190,17 +191,19 @@ async Task SimpleParameterSetExecuteCmdlet(IAsyncCmdlet asyncCmdlet)
NatBackendPort = imageAndOsType.OsType.UpdatePorts(NatBackendPort);

var inboundNatPoolName = VMScaleSetName;
var portRangeStart = 50000;
const int FirstPortRangeStart = 50000;
var portRangeStart = FirstPortRangeStart;
var PortRangeSize = InstanceCount * 2;
foreach (var natBackendPort in NatBackendPort)
{
inboundNatPools.Add(
loadBalancer.CreateInboundNatPool(
name: inboundNatPoolName + natBackendPort.ToString(),
frontendIpConfiguration: frontendIpConfiguration,
frontendPortRangeStart: portRangeStart,
frontendPortRangeEnd: portRangeStart + InstanceCount * 2,
frontendPortRangeEnd: portRangeStart + PortRangeSize,
backendPort: natBackendPort));
portRangeStart += 1000;
portRangeStart += 2000;
}

// generate a domain name label if it's not specified.
Expand Down Expand Up @@ -234,6 +237,24 @@ async Task SimpleParameterSetExecuteCmdlet(IAsyncCmdlet asyncCmdlet)
var psObject = new PSVirtualMachineScaleSet();
ComputeAutomationAutoMapperProfile.Mapper.Map(result, psObject);
psObject.FullyQualifiedDomainName = fqdn;

var port = "<port>";
var connectionString = imageAndOsType.GetConnectionString(
fqdn,
Credential.UserName,
port);
var range =
FirstPortRangeStart.ToString() +
".." +
(FirstPortRangeStart + PortRangeSize).ToString();

asyncCmdlet.WriteVerbose(
Resources.VmssUseConnectionString,
connectionString);
asyncCmdlet.WriteVerbose(
Resources.VmssPortRange,
port,
range);
asyncCmdlet.WriteObject(psObject);
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -572,4 +572,15 @@ The file needs to be a PowerShell script (.ps1 or .psm1) or a ZIP archive (.zip)
<value>Invalid ImageName {0}</value>
<comment>{0} = ImageName</comment>
</data>
<data name="VirtualMachineUseConnectionString" xml:space="preserve">
<value>Use '{0}' to connect to the VM.</value>
</data>
<data name="VmssPortRange" xml:space="preserve">
<value>Where {0} is in the range {1}.</value>
<comment>{0} = port, {1} = range</comment>
</data>
<data name="VmssUseConnectionString" xml:space="preserve">
<value>Use '{0}' to connect to the VMSS instances.</value>
<comment>{0} = connection string</comment>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ namespace Microsoft.Azure.Commands.Compute.Strategies
{
static class AsyncCmdletExtensions
{
public static void WriteVerbose(this IAsyncCmdlet cmdlet, string message, params object[] p)
=> cmdlet.WriteVerbose(string.Format(message, p));

/// <summary>
/// Note: the function must be called in the main PowerShell thread.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Microsoft.Azure.Commands.Compute.Strategies.ComputeRp
static class AvailabilitySetStrategy
{
public static ResourceStrategy<AvailabilitySet> Strategy { get; }
= ComputePolicy.Create(
= ComputeStrategy.Create(
provider: "availabilitySets",
getOperations: client => client.AvailabilitySets,
getAsync: (o, p) => o.GetAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace Microsoft.Azure.Commands.Compute.Strategies.ComputeRp
{
static class ComputePolicy
static class ComputeStrategy
{
public static ResourceStrategy<TModel> Create<TModel, TOperations>(
string provider,
Expand All @@ -38,5 +38,14 @@ public static ResourceStrategy<TModel> Create<TModel, TOperations>(
setLocation: (config, location) => config.Location = location,
createTime: createTime,
compulsoryLocation: true);

public static string GetConnectionString(
this ImageAndOsType imageAndOsType, string fqdn, string user, string port = null)
{
var url = fqdn + (port == null ? string.Empty : ":" + port);
return imageAndOsType.OsType == OperatingSystemTypes.Windows
? "mstsc /v:" + url
: "ssh " + user + "@" + url;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Microsoft.Azure.Commands.Compute.Strategies.ComputeRp
static class ManagedDiskStrategy
{
public static ResourceStrategy<Disk> Strategy { get; }
= ComputePolicy.Create(
= ComputeStrategy.Create(
provider: "disks",
getOperations: client => client.Disks,
getAsync: (o, p) => o.GetAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Microsoft.Azure.Commands.Compute.Strategies.ComputeRp
public static class VirtualMachineScaleSetStrategy
{
public static ResourceStrategy<VirtualMachineScaleSet> Strategy { get; }
= ComputePolicy.Create(
= ComputeStrategy.Create(
provider: "virtualMachineScaleSets",
getOperations: client => client.VirtualMachineScaleSets,
getAsync: (o, p) => o.GetAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Microsoft.Azure.Commands.Compute.Strategies.ComputeRp
static class VirtualMachineStrategy
{
public static ResourceStrategy<VirtualMachine> Strategy { get; }
= ComputePolicy.Create(
= ComputeStrategy.Create(
provider: "virtualMachines",
getOperations: client => client.VirtualMachines,
getAsync: (o, p) => o.GetAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Microsoft.Azure.Commands.Common.Strategies;
using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.Compute.Properties;
using Microsoft.Azure.Commands.Compute.StorageServices;
using Microsoft.Azure.Commands.Compute.Strategies;
using Microsoft.Azure.Commands.Compute.Strategies.ComputeRp;
Expand Down Expand Up @@ -405,9 +406,12 @@ async Task StrategyExecuteCmdletAsync(IAsyncCmdlet asyncCmdlet)
{
var psResult = ComputeAutoMapperProfile.Mapper.Map<PSVirtualMachine>(result);
psResult.FullyQualifiedDomainName = fqdn;
asyncCmdlet.WriteVerbose(imageAndOsType.OsType == OperatingSystemTypes.Windows
? "Use 'mstsc /v:" + fqdn + "' to connect to the VM."
: "Use 'ssh " + Credential.UserName + "@" + fqdn + "' to connect to the VM.");
var connectionString = imageAndOsType.GetConnectionString(
fqdn,
Credential.UserName);
asyncCmdlet.WriteVerbose(
Resources.VirtualMachineUseConnectionString,
connectionString);
asyncCmdlet.WriteObject(psResult);
}
}
Expand Down