Ejemplo n.º 1
0
 public static ResourceConfig <VirtualMachine> CreateVirtualMachineConfig(
     this ResourceConfig <ResourceGroup> resourceGroup,
     string name,
     ResourceConfig <NetworkInterface> networkInterface,
     Func <ImageAndOsType> getImageAndOsType,
     string adminUsername,
     string adminPassword,
     string size,
     ResourceConfig <AvailabilitySet> availabilitySet)
 => Strategy.CreateResourceConfig(
     resourceGroup: resourceGroup,
     name: name,
     createModel: subscription =>
 {
     var imageAndOsType = getImageAndOsType();
     return(new VirtualMachine
     {
         OsProfile = new OSProfile
         {
             ComputerName = name,
             WindowsConfiguration = imageAndOsType.OsType == OperatingSystemTypes.Windows
                         ? new WindowsConfiguration()
                         : null,
             LinuxConfiguration = imageAndOsType.OsType == OperatingSystemTypes.Linux
                         ? new LinuxConfiguration()
                         : null,
             AdminUsername = adminUsername,
             AdminPassword = adminPassword,
         },
         NetworkProfile = new NetworkProfile
         {
             NetworkInterfaces = new[]
             {
                 new NetworkInterfaceReference
                 {
                     Id = networkInterface.GetId(subscription).IdToString()
                 }
             }
         },
         HardwareProfile = new HardwareProfile
         {
             VmSize = size
         },
         StorageProfile = new StorageProfile
         {
             ImageReference = imageAndOsType.Image
         },
         AvailabilitySet = availabilitySet == null
                     ? null
                     : new Azure.Management.Compute.Models.SubResource
         {
             Id = availabilitySet.GetId(subscription).IdToString()
         }
     });
 },
     dependencies: new IResourceConfig[] { networkInterface, availabilitySet });
Ejemplo n.º 2
0
 public static ResourceConfig <VirtualMachine> CreateVirtualMachineConfig(
     this ResourceConfig <ResourceGroup> resourceGroup,
     string name,
     ResourceConfig <NetworkInterface> networkInterface,
     bool isWindows,
     string adminUsername,
     string adminPassword,
     Image image,
     string size,
     ResourceConfig <AvailabilitySet> availabilitySet)
 => Strategy.CreateResourceConfig(
     resourceGroup: resourceGroup,
     name: name,
     createModel: subscription => new VirtualMachine
 {
     OsProfile = new OSProfile
     {
         ComputerName         = name,
         WindowsConfiguration = isWindows ? new WindowsConfiguration {
         } : null,
         LinuxConfiguration   = isWindows ? null : new LinuxConfiguration(),
         AdminUsername        = adminUsername,
         AdminPassword        = adminPassword,
     },
     NetworkProfile = new NetworkProfile
     {
         NetworkInterfaces = new[]
         {
             new NetworkInterfaceReference
             {
                 Id = networkInterface.GetId(subscription).IdToString()
             }
         }
     },
     HardwareProfile = new HardwareProfile
     {
         VmSize = size
     },
     StorageProfile = new StorageProfile
     {
         ImageReference = new ImageReference
         {
             Publisher = image.publisher,
             Offer     = image.offer,
             Sku       = image.sku,
             Version   = image.version
         }
     },
     AvailabilitySet = availabilitySet == null
                 ? null
                 : new Azure.Management.Compute.Models.SubResource
     {
         Id = availabilitySet.GetId(subscription).IdToString()
     }
 },
     dependencies: new IResourceConfig[] { networkInterface, availabilitySet });
Ejemplo n.º 3
0
 public static ResourceConfig <VirtualMachine> CreateVirtualMachineConfig(
     this ResourceConfig <ResourceGroup> resourceGroup,
     string name,
     ResourceConfig <NetworkInterface> networkInterface,
     OperatingSystemTypes osType,
     ResourceConfig <Disk> disk,
     string size,
     ResourceConfig <AvailabilitySet> availabilitySet)
 => Strategy.CreateResourceConfig(
     resourceGroup: resourceGroup,
     name: name,
     createModel: subscription => new VirtualMachine
 {
     OsProfile      = null,
     NetworkProfile = new NetworkProfile
     {
         NetworkInterfaces = new[]
         {
             new NetworkInterfaceReference
             {
                 Id = networkInterface.GetId(subscription).IdToString()
             }
         }
     },
     HardwareProfile = new HardwareProfile
     {
         VmSize = size
     },
     StorageProfile = new StorageProfile
     {
         OsDisk = new OSDisk
         {
             Name         = disk.Name,
             CreateOption = DiskCreateOptionTypes.Attach,
             OsType       = osType,
             ManagedDisk  = new ManagedDiskParameters
             {
                 StorageAccountType = StorageAccountTypes.PremiumLRS,
                 Id = disk.GetId(subscription).IdToString()
             }
         }
     },
     AvailabilitySet = availabilitySet == null
                 ? null
                 : new Azure.Management.Compute.Models.SubResource
     {
         Id = availabilitySet.GetId(subscription).IdToString()
     }
 },
     dependencies: new IEntityConfig[] { networkInterface, disk, availabilitySet });
 public static ResourceConfig <VirtualMachine> CreateVirtualMachineConfig(
     this ResourceConfig <ResourceGroup> resourceGroup,
     string name,
     ResourceConfig <NetworkInterface> networkInterface,
     bool isWindows,
     ResourceConfig <Disk> disk,
     string size)
 => Strategy.CreateResourceConfig(
     resourceGroup: resourceGroup,
     name: name,
     createModel: subscription => new VirtualMachine
 {
     OsProfile      = null,
     NetworkProfile = new NetworkProfile
     {
         NetworkInterfaces = new[]
         {
             new NetworkInterfaceReference
             {
                 Id = networkInterface.GetId(subscription).IdToString()
             }
         }
     },
     HardwareProfile = new HardwareProfile
     {
         VmSize = size
     },
     StorageProfile = new StorageProfile
     {
         OsDisk = new OSDisk
         {
             Name         = disk.Name,
             CreateOption = DiskCreateOptionTypes.Attach,
             OsType       = isWindows ? OperatingSystemTypes.Windows : OperatingSystemTypes.Linux,
             ManagedDisk  = new ManagedDiskParameters
             {
                 StorageAccountType = StorageAccountTypes.PremiumLRS,
                 Id = disk.GetId(subscription).IdToString()
             }
         }
     },
 },
     dependencies: new IEntityConfig[] { networkInterface, disk });
Ejemplo n.º 5
0
        public static NestedResourceConfig <FrontendIPConfiguration, LoadBalancer> CreateFrontendIPConfiguration(
            this ResourceConfig <LoadBalancer> loadBalancer,
            string name,
            IList <string> zones,
            ResourceConfig <PublicIPAddress> publicIPAddress,
            NestedResourceConfig <Subnet, VirtualNetwork> subnet)
        => Strategy.CreateConfig(
            parent: loadBalancer,
            name: name,
            createModel: subscriptionId => {
            var frontEndConfig = CreateFrontendIpConfig(
                froontendPoolName: name,
                subscriptionId: subscriptionId,
                subnetId: subnet.GetId(subscriptionId).IdToString(),
                publicIpAddressId: publicIPAddress.GetId(subscriptionId).IdToString(),
                privateIpAddress: null,
                zones: zones);

            return(frontEndConfig);
        });
 public static ResourceConfig <NetworkInterface> CreateNetworkInterfaceConfig(
     this ResourceConfig <ResourceGroup> resourceGroup,
     string name,
     NestedResourceConfig <Subnet, VirtualNetwork> subnet,
     ResourceConfig <PublicIPAddress> publicIPAddress,
     ResourceConfig <NetworkSecurityGroup> networkSecurityGroup = null)
 => Strategy.CreateResourceConfig(
     resourceGroup: resourceGroup,
     name: name,
     createModel: subscription => new NetworkInterface
 {
     IpConfigurations = new []
     {
         new NetworkInterfaceIPConfiguration
         {
             Name   = name,
             Subnet = new Subnet {
                 Id = subnet.GetId(subscription).IdToString()
             },
             PublicIPAddress = new PublicIPAddress
             {
                 Id = publicIPAddress.GetId(subscription).IdToString()
             }
         }
     },
     NetworkSecurityGroup = networkSecurityGroup == null
                 ? null
                 : new NetworkSecurityGroup
     {
         Id = networkSecurityGroup.GetId(subscription).IdToString()
     }
 },
     dependencies: new IEntityConfig[]
 {
     subnet,
     publicIPAddress,
     networkSecurityGroup
 });