private PSBastion CreateBastion()
        {
            var bastion = new PSBastion()
            {
                Name = this.Name,
                ResourceGroupName = this.ResourceGroupName,
                Location          = this.VirtualNetwork.Location,
            };

            bastion.Sku       = new PSBastionSku();
            bastion.ScaleUnit = 2;

            if (!String.IsNullOrEmpty(this.Sku) || !String.IsNullOrWhiteSpace(this.Sku))
            {
                bastion.Sku.Name = this.Sku;
            }

            if (this.ScaleUnit.HasValue)
            {
                if (bastion.Sku.Name.Equals(MNM.BastionHostSkuName.Standard))
                {
                    if (this.ScaleUnit >= 2 && this.ScaleUnit <= 50)
                    {
                        bastion.ScaleUnit = this.ScaleUnit;
                    }
                    else
                    {
                        throw new ArgumentException("Please select scale units value between 2 and 50");
                    }
                }
                else if (bastion.Sku.Name.Equals(MNM.BastionHostSkuName.Basic) && this.ScaleUnit != 2)
                {
                    throw new ArgumentException("Scale Units cannot be updated with Basic Sku");
                }
            }

            if (this.VirtualNetwork != null)
            {
                bastion.Allocate(this.VirtualNetwork, this.PublicIpAddress);
            }

            //// Map to the sdk object
            var BastionModel = NetworkResourceManagerProfile.Mapper.Map <MNM.BastionHost>(bastion);

            BastionModel.ScaleUnits = bastion.ScaleUnit;
            BastionModel.Tags       = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true);

            //// Execute the Create bastion call
            this.BastionClient.CreateOrUpdate(this.ResourceGroupName, this.Name, BastionModel);

            return(this.GetBastion(this.ResourceGroupName, this.Name));
        }
Beispiel #2
0
        private PSBastion CreateBastion()
        {
            var bastion = new PSBastion()
            {
                Name = this.Name,
                ResourceGroupName = this.ResourceGroupName,
                Location          = this.VirtualNetwork.Location
            };

            if (this.VirtualNetwork != null)
            {
                bastion.Allocate(this.VirtualNetwork, this.PublicIpAddress);
            }

            //// Map to the sdk object
            var BastionModel = NetworkResourceManagerProfile.Mapper.Map <MNM.BastionHost>(bastion);

            BastionModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true);

            //// Execute the Create bastion call
            this.BastionClient.CreateOrUpdate(this.ResourceGroupName, this.Name, BastionModel);

            return(this.GetBastion(this.ResourceGroupName, this.Name));
        }