Skip to content

Commit 7c247af

Browse files
FQDN
1 parent c7c883f commit 7c247af

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Operation/NewAzureVMCommand.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ async Task StrategyExecuteCmdletAsync(IAsyncCmdlet asyncCmdlet)
187187
.Select(nameAndImage => new { OsType = osAndMap.Key, Image = nameAndImage.Value }))
188188
.FirstOrDefault();
189189

190-
OpenPorts = OpenPorts
191-
?? (image.OsType == "Windows" ? new[] { 3389, 5985 } : new[] { 22 });
190+
var isWindows = image.OsType == "Windows";
191+
OpenPorts = OpenPorts ?? (isWindows ? new[] { 3389, 5985 } : new[] { 22 });
192192

193193
var resourceGroup = ResourceGroupStrategy.CreateResourceGroupConfig(ResourceGroupName);
194194
var virtualNetwork = resourceGroup.CreateVirtualNetworkConfig(
@@ -224,6 +224,8 @@ async Task StrategyExecuteCmdletAsync(IAsyncCmdlet asyncCmdlet)
224224
}
225225
}
226226

227+
var fqdn = DomainNameLabel + "." + Location + ".cloudapp.azure.com";
228+
227229
// create target state
228230
var target = virtualMachine.GetTargetState(current, client.SubscriptionId, Location);
229231

@@ -238,6 +240,10 @@ async Task StrategyExecuteCmdletAsync(IAsyncCmdlet asyncCmdlet)
238240

239241
var result = newState.Get(virtualMachine);
240242
var psResult = ComputeAutoMapperProfile.Mapper.Map<PSVirtualMachine>(result);
243+
psResult.Fqdn = fqdn;
244+
asyncCmdlet.WriteVerbose(isWindows
245+
? "Use 'mstsc /v:" + fqdn + "' to connect to the VM."
246+
: "Use 'ssh " + Credential.UserName + "@" + fqdn + "' to connect to the VM.");
241247
asyncCmdlet.WriteObject(psResult);
242248
}
243249

0 commit comments

Comments
 (0)