Skip to content

Commit

Permalink
Image name
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-shandar committed Nov 27, 2017
1 parent 03392cf commit d691559
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public static ResourceConfig<VirtualMachine> CreateVirtualMachineConfig(
string name,
ResourceConfig<NetworkInterface> networkInterface,
string adminUsername,
string adminPassword)
string adminPassword,
Image image)
=> Strategy.CreateConfig(
resourceGroup,
name,
Expand Down Expand Up @@ -54,10 +55,10 @@ public static ResourceConfig<VirtualMachine> CreateVirtualMachineConfig(
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest"
Publisher = image.publisher,
Offer = image.offer,
Sku = image.sku,
Version = image.version
}
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
using System.Collections;
using System.Linq;
using System.Management.Automation;
using System.Net;
using System.Reflection;
using System.Threading;
using CM = Microsoft.Azure.Management.Compute.Models;
Expand Down Expand Up @@ -189,7 +190,7 @@ public void StrategyExecuteCmdlet()
VirtualNetworkName = VirtualNetworkName ?? Name;
SubnetName = SubnetName ?? Name;
PublicIpAddressName = PublicIpAddressName ?? Name;
DomainNameLabel = DomainNameLabel ?? (Name + ResourceGroupName);
DomainNameLabel = DomainNameLabel ?? (Name + ResourceGroupName).ToLower();
SecurityGroupName = SecurityGroupName ?? Name;

// get image
Expand All @@ -199,6 +200,9 @@ public void StrategyExecuteCmdlet()
new { OsType = osAndMap.Key, Image = osAndMap.Value.GetOrNull(ImageName) })
.First(osAndImage => osAndImage.Image != null);

OpenPorts = OpenPorts
?? (image.OsType == "Windows" ? new[] { 3389, 5985 } : new[] { 22 });

var resourceGroup = ResourceGroupStrategy.CreateResourceGroupConfig(ResourceGroupName);
var virtualNetwork = resourceGroup.CreateVirtualNetworkConfig(
name: VirtualNetworkName, addressPrefix: AddressPrefix);
Expand All @@ -213,10 +217,11 @@ public void StrategyExecuteCmdlet()
var networkInterface = resourceGroup.CreateNetworkInterfaceConfig(
Name, subnet, publicIpAddress, networkSecurityGroup);
var virtualMachine = resourceGroup.CreateVirtualMachineConfig(
Name,
networkInterface,
Credential.UserName,
new System.Net.NetworkCredential(string.Empty, Credential.Password).Password);
name: Name,
networkInterface: networkInterface,
adminUsername: Credential.UserName,
adminPassword: new NetworkCredential(string.Empty, Credential.Password).Password,
image: image.Image);

//
var client = new Client(DefaultProfile.DefaultContext);
Expand Down

0 comments on commit d691559

Please sign in to comment.