diff --git a/src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Operation/NewAzureVMCommand.cs b/src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Operation/NewAzureVMCommand.cs index fbde56dc81f7..c7684c5d2dde 100644 --- a/src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Operation/NewAzureVMCommand.cs +++ b/src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Operation/NewAzureVMCommand.cs @@ -187,8 +187,8 @@ async Task StrategyExecuteCmdletAsync(IAsyncCmdlet asyncCmdlet) .Select(nameAndImage => new { OsType = osAndMap.Key, Image = nameAndImage.Value })) .FirstOrDefault(); - OpenPorts = OpenPorts - ?? (image.OsType == "Windows" ? new[] { 3389, 5985 } : new[] { 22 }); + var isWindows = image.OsType == "Windows"; + OpenPorts = OpenPorts ?? (isWindows ? new[] { 3389, 5985 } : new[] { 22 }); var resourceGroup = ResourceGroupStrategy.CreateResourceGroupConfig(ResourceGroupName); var virtualNetwork = resourceGroup.CreateVirtualNetworkConfig( @@ -224,6 +224,8 @@ async Task StrategyExecuteCmdletAsync(IAsyncCmdlet asyncCmdlet) } } + var fqdn = DomainNameLabel + "." + Location + ".cloudapp.azure.com"; + // create target state var target = virtualMachine.GetTargetState(current, client.SubscriptionId, Location); @@ -238,6 +240,10 @@ async Task StrategyExecuteCmdletAsync(IAsyncCmdlet asyncCmdlet) var result = newState.Get(virtualMachine); var psResult = ComputeAutoMapperProfile.Mapper.Map(result); + psResult.Fqdn = fqdn; + asyncCmdlet.WriteVerbose(isWindows + ? "Use 'mstsc /v:" + fqdn + "' to connect to the VM." + : "Use 'ssh " + Credential.UserName + "@" + fqdn + "' to connect to the VM."); asyncCmdlet.WriteObject(psResult); }