public static ResourceConfig <NetworkInterface> CreateNetworkInterfaceConfig(
     this ResourceConfig <ResourceGroup> resourceGroup,
     string name,
     string edgeZone,
     NestedResourceConfig <Subnet, VirtualNetwork> subnet,
     ResourceConfig <PublicIPAddress> publicIPAddress,
     ResourceConfig <NetworkSecurityGroup> networkSecurityGroup = null,
     bool enableAcceleratedNetworking = false)
 => Strategy.CreateResourceConfig(
     resourceGroup: resourceGroup,
     name: name,
     createModel: engine => new NetworkInterface
 {
     EnableAcceleratedNetworking = enableAcceleratedNetworking,
     IpConfigurations            = new []
     {
         new NetworkInterfaceIPConfiguration
         {
             Name            = name,
             Subnet          = engine.GetReference(subnet),
             PublicIPAddress = engine.GetReference(publicIPAddress)
         }
     },
     NetworkSecurityGroup = networkSecurityGroup == null
                 ? null
                 : engine.GetReference(networkSecurityGroup),
     ExtendedLocation = edgeZone == null
                 ? null
                 : new ExtendedLocation {
         Name = edgeZone
     }
 });
Beispiel #2
0
 public static TModel GetReference <TModel, TParentModel>(
     this IEngine engine, NestedResourceConfig <TModel, TParentModel> config)
     where TModel : SubResource, new()
     where TParentModel : Resource
 => new TModel
 {
     Id = engine.GetId(config)
 };
        /// <summary>
        /// Get a model of the given nested resource config from the given state.
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <typeparam name="TParentModel"></typeparam>
        /// <param name="state"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public static TModel Get <TModel, TParentModel>(
            this IState state, NestedResourceConfig <TModel, TParentModel> config)
            where TModel : class
            where TParentModel : class
        {
            var parentModel = state.GetDispatch(config.Parent);

            return(parentModel == null ? null : config.Strategy.Get(parentModel, config.Name));
        }
 public static NestedResourceConfig <InboundNatPool, LoadBalancer> CreateInboundNatPool(
     this ResourceConfig <LoadBalancer> loadBalancer,
     string name,
     NestedResourceConfig <FrontendIPConfiguration, LoadBalancer> frontendIpConfiguration,
     int frontendPortRangeStart,
     int frontendPortRangeEnd,
     int backendPort)
 => loadBalancer.CreateNested(
     Strategy,
     name,
     engine => new InboundNatPool
 {
     FrontendIPConfiguration = engine.GetReference(frontendIpConfiguration),
     Protocol = NetworkStrategy.Tcp,
     FrontendPortRangeStart = frontendPortRangeStart,
     FrontendPortRangeEnd   = frontendPortRangeEnd,
     BackendPort            = backendPort
 });
Beispiel #5
0
 public static NestedResourceConfig <LoadBalancingRule, LoadBalancer> CreateLoadBalancingRule(
     this ResourceConfig <LoadBalancer> loadBalancer,
     string name,
     NestedResourceConfig <FrontendIPConfiguration, LoadBalancer> fronendIpConfiguration,
     NestedResourceConfig <BackendAddressPool, LoadBalancer> backendAddressPool,
     int frontendPort,
     int backendPort)
 => loadBalancer.CreateNested(
     Strategy,
     name,
     engine => new LoadBalancingRule
 {
     FrontendIPConfiguration = engine.GetReference(fronendIpConfiguration),
     BackendAddressPool      = engine.GetReference(backendAddressPool),
     Protocol     = NetworkStrategy.Tcp,
     FrontendPort = frontendPort,
     BackendPort  = backendPort,
 });
 public static ResourceConfig <LoadBalancer> CreateLoadBalancerConfig(
     this ResourceConfig <ResourceGroup> resourceGroup,
     string name,
     string froontendPoolName,
     string backendPoolName,
     IList <string> zones,
     ResourceConfig <PublicIPAddress> publicIPAddress,
     NestedResourceConfig <Subnet, VirtualNetwork> subnet)
 => Strategy.CreateResourceConfig(
     resourceGroup: resourceGroup,
     name: name,
     createModel: subscriptionId =>
 {
     var lb = new LoadBalancer();
     NormalizeChildResourcesId(lb, subscriptionId, resourceGroup.Name);
     return(lb);
 },
     dependencies: new IEntityConfig[] { subnet, publicIPAddress });
Beispiel #7
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
 });
Beispiel #9
0
 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: engine => new NetworkInterface
 {
     IpConfigurations = new []
     {
         new NetworkInterfaceIPConfiguration
         {
             Name            = name,
             Subnet          = engine.GetReference(subnet),
             PublicIPAddress = engine.GetReference(publicIPAddress)
         }
     },
     NetworkSecurityGroup = networkSecurityGroup == null
                 ? null
                 : engine.GetReference(networkSecurityGroup)
 });
 internal static ResourceConfig <VirtualMachineScaleSet> CreateVirtualMachineScaleSetConfigOrchestrationModeFlexible(
     this ResourceConfig <ResourceGroup> resourceGroup,
     string name,
     NestedResourceConfig <Subnet, VirtualNetwork> subnet,
     NestedResourceConfig <BackendAddressPool, LoadBalancer> backendAdressPool,
     ResourceConfig <NetworkSecurityGroup> networkSecurityGroup,
     ImageAndOsType imageAndOsType,
     string adminUsername,
     string adminPassword,
     string vmSize,
     int instanceCount,
     VirtualMachineScaleSetIdentity identity,
     bool singlePlacementGroup,
     IEnumerable <int> dataDisks,
     IList <string> zones,
     bool ultraSSDEnabled,
     Func <IEngine, CM.SubResource> proximityPlacementGroup,
     Func <IEngine, CM.SubResource> hostGroup,
     string priority,
     string evictionPolicy,
     double?maxPrice,
     string[] scaleInPolicy,
     bool doNotRunExtensionsOnOverprovisionedVMs,
     bool encryptionAtHost,
     int?platformFaultDomainCount,
     string edgeZone,
     string orchestrationMode,
     string capacityReservationId
     )
 => Strategy.CreateResourceConfig(
     resourceGroup: resourceGroup,
     name: name,
     createModel: engine => new VirtualMachineScaleSet()
 {
     Zones            = zones,
     ExtendedLocation = edgeZone == null ? null : new CM.ExtendedLocation(edgeZone, CM.ExtendedLocationTypes.EdgeZone),
     Sku = new Azure.Management.Compute.Models.Sku()
     {
         Capacity = instanceCount,
         Name     = vmSize,
     },
     Identity                 = identity,
     SinglePlacementGroup     = singlePlacementGroup,
     AdditionalCapabilities   = ultraSSDEnabled ? new AdditionalCapabilities(true) : null,
     PlatformFaultDomainCount = platformFaultDomainCount,
     VirtualMachineProfile    = new VirtualMachineScaleSetVMProfile
     {
         SecurityProfile = (encryptionAtHost == true) ? new SecurityProfile(encryptionAtHost: encryptionAtHost) : null,
         OsProfile       = new VirtualMachineScaleSetOSProfile
         {
             ComputerNamePrefix   = name.Substring(0, Math.Min(name.Length, 9)),
             WindowsConfiguration = imageAndOsType.CreateWindowsConfiguration(),
             LinuxConfiguration   = imageAndOsType.CreateLinuxConfiguration(),
             AdminUsername        = adminUsername,
             AdminPassword        = adminPassword,
         },
         StorageProfile = new VirtualMachineScaleSetStorageProfile
         {
             ImageReference = imageAndOsType?.Image,
             DataDisks      = DataDiskStrategy.CreateVmssDataDisks(
                 imageAndOsType?.DataDiskLuns, dataDisks)
         },
         NetworkProfile = new VirtualMachineScaleSetNetworkProfile
         {
             NetworkApiVersion = flexibleOModeNetworkAPIVersion,
             NetworkInterfaceConfigurations = new[]
             {
                 new VirtualMachineScaleSetNetworkConfiguration
                 {
                     Name             = name,
                     IpConfigurations = new []
                     {
                         new VirtualMachineScaleSetIPConfiguration
                         {
                             Name = name,
                             LoadBalancerBackendAddressPools = new []
                             {
                                 engine.GetReference(backendAdressPool)
                             },
                             Subnet = engine.GetReference(subnet)
                         }
                     },
                     Primary = true,
                     NetworkSecurityGroup = engine.GetReference(networkSecurityGroup)
                 }
             }
         },
         Priority            = priority,
         EvictionPolicy      = evictionPolicy,
         BillingProfile      = (maxPrice == null) ? null : new BillingProfile(maxPrice),
         CapacityReservation = (capacityReservationId == null) ? null : new CapacityReservationProfile
         {
             CapacityReservationGroup = new Microsoft.Azure.Management.Compute.Models.SubResource(capacityReservationId)
         }
     },
     ProximityPlacementGroup = proximityPlacementGroup(engine),
     HostGroup     = hostGroup(engine),
     ScaleInPolicy = (scaleInPolicy == null) ? null : new ScaleInPolicy
     {
         Rules = scaleInPolicy
     },
     DoNotRunExtensionsOnOverprovisionedVMs = doNotRunExtensionsOnOverprovisionedVMs ? true : (bool?)null,
     OrchestrationMode = orchestrationMode
 });
 internal static ResourceConfig <VirtualMachineScaleSet> CreateVirtualMachineScaleSetConfig(
     this ResourceConfig <ResourceGroup> resourceGroup,
     string name,
     NestedResourceConfig <Subnet, VirtualNetwork> subnet,
     NestedResourceConfig <BackendAddressPool, LoadBalancer> backendAdressPool,
     IEnumerable <NestedResourceConfig <InboundNatPool, LoadBalancer> > inboundNatPools,
     ResourceConfig <NetworkSecurityGroup> networkSecurityGroup,
     ImageAndOsType imageAndOsType,
     string adminUsername,
     string adminPassword,
     string vmSize,
     int instanceCount,
     VirtualMachineScaleSetIdentity identity,
     Boolean singlePlacementGroup,
     UpgradeMode?upgradeMode,
     IEnumerable <int> dataDisks,
     IList <string> zones)
 => Strategy.CreateResourceConfig(
     resourceGroup: resourceGroup,
     name: name,
     createModel: engine => new VirtualMachineScaleSet()
 {
     Zones         = zones,
     UpgradePolicy = new UpgradePolicy
     {
         Mode = upgradeMode ?? UpgradeMode.Manual
     },
     Sku = new Azure.Management.Compute.Models.Sku()
     {
         Capacity = instanceCount,
         Name     = vmSize,
     },
     Identity              = identity,
     SinglePlacementGroup  = singlePlacementGroup,
     VirtualMachineProfile = new VirtualMachineScaleSetVMProfile
     {
         OsProfile = new VirtualMachineScaleSetOSProfile
         {
             ComputerNamePrefix   = name.Substring(0, Math.Min(name.Length, 9)),
             WindowsConfiguration = imageAndOsType.CreateWindowsConfiguration(),
             LinuxConfiguration   = imageAndOsType.CreateLinuxConfiguration(),
             AdminUsername        = adminUsername,
             AdminPassword        = adminPassword,
         },
         StorageProfile = new VirtualMachineScaleSetStorageProfile
         {
             ImageReference = imageAndOsType?.Image,
             DataDisks      = DataDiskStrategy.CreateVmssDataDisks(
                 imageAndOsType?.DataDiskLuns, dataDisks)
         },
         NetworkProfile = new VirtualMachineScaleSetNetworkProfile
         {
             NetworkInterfaceConfigurations = new[]
             {
                 new VirtualMachineScaleSetNetworkConfiguration
                 {
                     Name             = name,
                     IpConfigurations = new []
                     {
                         new VirtualMachineScaleSetIPConfiguration
                         {
                             Name = name,
                             LoadBalancerBackendAddressPools = new []
                             {
                                 engine.GetReference(backendAdressPool)
                             },
                             Subnet = engine.GetReference(subnet),
                             LoadBalancerInboundNatPools = inboundNatPools
                                                           ?.Select(engine.GetReference)
                                                           .ToList()
                         }
                     },
                     Primary = true,
                     NetworkSecurityGroup = engine.GetReference(networkSecurityGroup)
                 }
             }
         }
     }
 });
 internal static ResourceConfig <VirtualMachineScaleSet> CreateVirtualMachineScaleSetConfig(
     this ResourceConfig <ResourceGroup> resourceGroup,
     string name,
     NestedResourceConfig <Subnet, VirtualNetwork> subnet,
     NestedResourceConfig <BackendAddressPool, LoadBalancer> backendAdressPool,
     IEnumerable <NestedResourceConfig <InboundNatPool, LoadBalancer> > inboundNatPools,
     ResourceConfig <NetworkSecurityGroup> networkSecurityGroup,
     ImageAndOsType imageAndOsType,
     string adminUsername,
     string adminPassword,
     string vmSize,
     int instanceCount,
     VirtualMachineScaleSetIdentity identity,
     bool singlePlacementGroup,
     UpgradeMode?upgradeMode,
     IEnumerable <int> dataDisks,
     IList <string> zones,
     bool ultraSSDEnabled,
     Func <IEngine, SubResource> proximityPlacementGroup,
     string priority,
     string evictionPolicy,
     double?maxPrice,
     string[] scaleInPolicy,
     bool doNotRunExtensionsOnOverprovisionedVMs)
 => Strategy.CreateResourceConfig(
     resourceGroup: resourceGroup,
     name: name,
     createModel: engine => new VirtualMachineScaleSet()
 {
     Zones         = zones,
     UpgradePolicy = new UpgradePolicy
     {
         Mode = upgradeMode ?? UpgradeMode.Manual
     },
     Sku = new Azure.Management.Compute.Models.Sku()
     {
         Capacity = instanceCount,
         Name     = vmSize,
     },
     Identity               = identity,
     SinglePlacementGroup   = singlePlacementGroup,
     AdditionalCapabilities = ultraSSDEnabled ? new AdditionalCapabilities(true) : null,
     VirtualMachineProfile  = new VirtualMachineScaleSetVMProfile
     {
         OsProfile = new VirtualMachineScaleSetOSProfile
         {
             ComputerNamePrefix   = name.Substring(0, Math.Min(name.Length, 9)),
             WindowsConfiguration = imageAndOsType.CreateWindowsConfiguration(),
             LinuxConfiguration   = imageAndOsType.CreateLinuxConfiguration(),
             AdminUsername        = adminUsername,
             AdminPassword        = adminPassword,
         },
         StorageProfile = new VirtualMachineScaleSetStorageProfile
         {
             ImageReference = imageAndOsType?.Image,
             DataDisks      = DataDiskStrategy.CreateVmssDataDisks(
                 imageAndOsType?.DataDiskLuns, dataDisks)
         },
         NetworkProfile = new VirtualMachineScaleSetNetworkProfile
         {
             NetworkInterfaceConfigurations = new[]
             {
                 new VirtualMachineScaleSetNetworkConfiguration
                 {
                     Name             = name,
                     IpConfigurations = new []
                     {
                         new VirtualMachineScaleSetIPConfiguration
                         {
                             Name = name,
                             LoadBalancerBackendAddressPools = new []
                             {
                                 engine.GetReference(backendAdressPool)
                             },
                             Subnet = engine.GetReference(subnet),
                             LoadBalancerInboundNatPools = inboundNatPools
                                                           ?.Select(engine.GetReference)
                                                           .ToList()
                         }
                     },
                     Primary = true,
                     NetworkSecurityGroup = engine.GetReference(networkSecurityGroup)
                 }
             }
         },
         Priority       = priority,
         EvictionPolicy = evictionPolicy,
         BillingProfile = (maxPrice == null) ? null : new BillingProfile(maxPrice)
     },
     ProximityPlacementGroup = proximityPlacementGroup(engine),
     ScaleInPolicy           = (scaleInPolicy == null) ? null : new ScaleInPolicy
     {
         Rules = scaleInPolicy
     },
     DoNotRunExtensionsOnOverprovisionedVMs = doNotRunExtensionsOnOverprovisionedVMs ? true : (bool?)null
 });
 public static SubResource GetReference(
     this IEngine engine,
     NestedResourceConfig <N.BackendAddressPool, N.LoadBalancer> backendAddressPool)
 => engine.GetSubResourceReference(backendAddressPool);
 public static bool Contains <TModel, TParentModel>(
     this IState state, NestedResourceConfig <TModel, TParentModel> config)
     where TModel : class
     where TParentModel : class
 => state.Get(config) != null;
 public bool Visit <TModel, TParentModel>(
     NestedResourceConfig <TModel, TParentModel> config, IState context)
     where TModel : class
     where TParentModel : class
 => context.IsCurrentPresentAndCompatible(config);
        internal static ResourceConfig <VirtualMachineScaleSet> CreateVirtualMachineScaleSetConfig(
            this ResourceConfig <ResourceGroup> resourceGroup,
            string name,
            NestedResourceConfig <Subnet, VirtualNetwork> subnet,
            IEnumerable <NestedResourceConfig <FrontendIPConfiguration, LoadBalancer> > frontendIpConfigurations,
            NestedResourceConfig <BackendAddressPool, LoadBalancer> backendAdressPool,
            bool isWindows,
            string adminUsername,
            string adminPassword,
            Image image,
            string vmSize,
            int instanceCount,
            UpgradeMode?upgradeMode)
        => Strategy.CreateResourceConfig(
            resourceGroup: resourceGroup,
            name: name,
            createModel: subscriptionId =>
        {
            var vmss = new VirtualMachineScaleSet()
            {
                Zones = frontendIpConfigurations
                        ?.Select(f => f.CreateModel(subscriptionId))
                        ?.Where(z => z?.Zones != null)
                        .SelectMany(z => z.Zones)
                        .Where(z => z != null)
                        .ToList(),

                UpgradePolicy = upgradeMode.HasValue ?
                                new UpgradePolicy
                {
                    Mode = upgradeMode
                }
                            : new UpgradePolicy
                {
                    Mode = UpgradeMode.Manual
                },

                Sku = new Microsoft.Azure.Management.Compute.Models.Sku()
                {
                    Capacity = instanceCount,
                    Name     = vmSize,
                },
                VirtualMachineProfile = new VirtualMachineScaleSetVMProfile()
            };

            vmss.VirtualMachineProfile.OsProfile = new VirtualMachineScaleSetOSProfile
            {
                ComputerNamePrefix   = name.Substring(0, Math.Min(name.Length, 9)),
                WindowsConfiguration = isWindows ? new WindowsConfiguration {
                } : null,
                LinuxConfiguration   = isWindows ? null : new LinuxConfiguration(),
                AdminUsername        = adminUsername,
                AdminPassword        = adminPassword,
            };

            vmss.VirtualMachineProfile.StorageProfile = new VirtualMachineScaleSetStorageProfile
            {
                ImageReference = new ImageReference
                {
                    Publisher = image.publisher,
                    Offer     = image.offer,
                    Sku       = image.sku,
                    Version   = image.version
                }
            };

            var ipConfig = new VirtualMachineScaleSetIPConfiguration
            {
                Name = name,
                LoadBalancerBackendAddressPools = new List <Microsoft.Azure.Management.Compute.Models.SubResource>(
                    new[] {
                    new Microsoft.Azure.Management.Compute.Models.SubResource(
                        id: backendAdressPool.GetId(subscriptionId).IdToString())
                }),
                Subnet = new ApiEntityReference {
                    Id = subnet.GetId(subscriptionId).IdToString()
                }
            };


            vmss.VirtualMachineProfile.NetworkProfile = new VirtualMachineScaleSetNetworkProfile
            {
                NetworkInterfaceConfigurations = new[]
                {
                    new VirtualMachineScaleSetNetworkConfiguration
                    {
                        Name             = name,
                        IpConfigurations = new List <VirtualMachineScaleSetIPConfiguration>(
                            new [] { ipConfig }),
                        Primary = true
                    }
                }
            };


            return(vmss);
        },
            dependencies: new IEntityConfig[] { subnet, backendAdressPool }
            .Concat(frontendIpConfigurations));
 //As of now this is just checking presence, we will revisit this later
 //If sub resources need this functionality
 public static bool IsCurrentPresentAndCompatible <TModel, TParentModel>(
     this IState state, NestedResourceConfig <TModel, TParentModel> config)
     where TModel : class
     where TParentModel : class
 => state.Get(config) != null;
 public TModel Visit <TParentModel>(
     NestedResourceConfig <TModel, TParentModel> config, IState state)
     where TParentModel : class
 => state.Get(config);
 public static SubResource GetReference(
     this IEngine engine,
     NestedResourceConfig <N.InboundNatPool, N.LoadBalancer> inboundNatPool)
 => engine.GetSubResourceReference(inboundNatPool);
 public bool Visit <TModel, TParentModel>(
     NestedResourceConfig <TModel, TParentModel> config, IState context)
     where TModel : class
     where TParentModel : class
 => context.Contains(config);
        internal static ResourceConfig <VirtualMachineScaleSet> CreateVirtualMachineScaleSetConfig(
            this ResourceConfig <ResourceGroup> resourceGroup,
            string name,
            NestedResourceConfig <Subnet, VirtualNetwork> subnet,
            IEnumerable <NestedResourceConfig <FrontendIPConfiguration, LoadBalancer> > frontendIpConfigurations,
            NestedResourceConfig <BackendAddressPool, LoadBalancer> backendAdressPool,
            IEnumerable <NestedResourceConfig <InboundNatPool, LoadBalancer> > inboundNatPools,
            Func <ImageAndOsType> getImageAndOsType,
            string adminUsername,
            string adminPassword,
            string vmSize,
            int instanceCount,
            UpgradeMode?upgradeMode)
        => Strategy.CreateResourceConfig(
            resourceGroup: resourceGroup,
            name: name,
            createModel: engine =>
        {
            var imageAndOsType = getImageAndOsType();
            return(new VirtualMachineScaleSet()
            {
                Zones = frontendIpConfigurations
                        ?.Select(f => f.CreateModel(engine))
                        ?.Where(z => z?.Zones != null)
                        .SelectMany(z => z.Zones)
                        .Where(z => z != null)
                        .ToList(),

                UpgradePolicy = new UpgradePolicy
                {
                    Mode = upgradeMode ?? UpgradeMode.Manual
                },

                Sku = new Azure.Management.Compute.Models.Sku()
                {
                    Capacity = instanceCount,
                    Name = vmSize,
                },
                VirtualMachineProfile = new VirtualMachineScaleSetVMProfile
                {
                    OsProfile = new VirtualMachineScaleSetOSProfile
                    {
                        ComputerNamePrefix = name.Substring(0, Math.Min(name.Length, 9)),
                        WindowsConfiguration = imageAndOsType.CreateWindowsConfiguration(),
                        LinuxConfiguration = imageAndOsType.CreateLinuxConfiguration(),
                        AdminUsername = adminUsername,
                        AdminPassword = adminPassword,
                    },
                    StorageProfile = new VirtualMachineScaleSetStorageProfile
                    {
                        ImageReference = imageAndOsType.Image
                    },
                    NetworkProfile = new VirtualMachineScaleSetNetworkProfile
                    {
                        NetworkInterfaceConfigurations = new[]
                        {
                            new VirtualMachineScaleSetNetworkConfiguration
                            {
                                Name = name,
                                IpConfigurations = new []
                                {
                                    new VirtualMachineScaleSetIPConfiguration
                                    {
                                        Name = name,
                                        LoadBalancerBackendAddressPools = new []
                                        {
                                            engine.GetReference(backendAdressPool)
                                        },
                                        Subnet = engine.GetReference(subnet),
                                        LoadBalancerInboundNatPools = inboundNatPools
                                                                      .Select(engine.GetReference)
                                                                      .ToList()
                                    }
                                },
                                Primary = true
                            }
                        }
                    }
                }
            });
        });
Beispiel #22
0
 public static ApiEntityReference GetReference(
     this IEngine engine, NestedResourceConfig <Subnet, VirtualNetwork> subnet)
 => new ApiEntityReference
 {
     Id = engine.GetId(subnet)
 };