Example #1
0
        private void Run()
        {
            // OrchestratorProfile
            Microsoft.Azure.Management.Compute.Models.ContainerServiceOrchestratorProfile vOrchestratorProfile = null;

            // CustomProfile
            Microsoft.Azure.Management.Compute.Models.ContainerServiceCustomProfile vCustomProfile = null;

            // ServicePrincipalProfile
            Microsoft.Azure.Management.Compute.Models.ContainerServiceServicePrincipalProfile vServicePrincipalProfile = null;

            // MasterProfile
            Microsoft.Azure.Management.Compute.Models.ContainerServiceMasterProfile vMasterProfile = null;

            // WindowsProfile
            Microsoft.Azure.Management.Compute.Models.ContainerServiceWindowsProfile vWindowsProfile = null;

            // LinuxProfile
            Microsoft.Azure.Management.Compute.Models.ContainerServiceLinuxProfile vLinuxProfile = null;

            // DiagnosticsProfile
            Microsoft.Azure.Management.Compute.Models.ContainerServiceDiagnosticsProfile vDiagnosticsProfile = null;

            if (this.OrchestratorType.HasValue)
            {
                if (vOrchestratorProfile == null)
                {
                    vOrchestratorProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceOrchestratorProfile();
                }
                vOrchestratorProfile.OrchestratorType = this.OrchestratorType.Value;
            }

            if (this.CustomProfileOrchestrator != null)
            {
                if (vCustomProfile == null)
                {
                    vCustomProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceCustomProfile();
                }
                vCustomProfile.Orchestrator = this.CustomProfileOrchestrator;
            }

            if (this.ServicePrincipalProfileClientId != null)
            {
                if (vServicePrincipalProfile == null)
                {
                    vServicePrincipalProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceServicePrincipalProfile();
                }
                vServicePrincipalProfile.ClientId = this.ServicePrincipalProfileClientId;
            }

            if (this.ServicePrincipalProfileSecret != null)
            {
                if (vServicePrincipalProfile == null)
                {
                    vServicePrincipalProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceServicePrincipalProfile();
                }
                vServicePrincipalProfile.Secret = this.ServicePrincipalProfileSecret;
            }

            if (this.MasterCount != null)
            {
                if (vMasterProfile == null)
                {
                    vMasterProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceMasterProfile();
                }
                vMasterProfile.Count = this.MasterCount;
            }

            if (this.MasterDnsPrefix != null)
            {
                if (vMasterProfile == null)
                {
                    vMasterProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceMasterProfile();
                }
                vMasterProfile.DnsPrefix = this.MasterDnsPrefix;
            }

            if (this.WindowsProfileAdminUsername != null)
            {
                if (vWindowsProfile == null)
                {
                    vWindowsProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceWindowsProfile();
                }
                vWindowsProfile.AdminUsername = this.WindowsProfileAdminUsername;
            }

            if (this.WindowsProfileAdminPassword != null)
            {
                if (vWindowsProfile == null)
                {
                    vWindowsProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceWindowsProfile();
                }
                vWindowsProfile.AdminPassword = this.WindowsProfileAdminPassword;
            }

            if (this.AdminUsername != null)
            {
                if (vLinuxProfile == null)
                {
                    vLinuxProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceLinuxProfile();
                }
                vLinuxProfile.AdminUsername = this.AdminUsername;
            }


            if (this.SshPublicKey != null)
            {
                if (vLinuxProfile == null)
                {
                    vLinuxProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceLinuxProfile();
                }
                if (vLinuxProfile.Ssh == null)
                {
                    vLinuxProfile.Ssh = new Microsoft.Azure.Management.Compute.Models.ContainerServiceSshConfiguration();
                }
                if (vLinuxProfile.Ssh.PublicKeys == null)
                {
                    vLinuxProfile.Ssh.PublicKeys = new List <Microsoft.Azure.Management.Compute.Models.ContainerServiceSshPublicKey>();
                }
                foreach (var element in this.SshPublicKey)
                {
                    var vPublicKeys = new Microsoft.Azure.Management.Compute.Models.ContainerServiceSshPublicKey();
                    vPublicKeys.KeyData = element;
                    vLinuxProfile.Ssh.PublicKeys.Add(vPublicKeys);
                }
            }

            if (vDiagnosticsProfile == null)
            {
                vDiagnosticsProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceDiagnosticsProfile();
            }
            if (vDiagnosticsProfile.VmDiagnostics == null)
            {
                vDiagnosticsProfile.VmDiagnostics = new Microsoft.Azure.Management.Compute.Models.ContainerServiceVMDiagnostics();
            }

            vDiagnosticsProfile.VmDiagnostics.Enabled = this.VmDiagnosticsEnabled;

            var vContainerService = new PSContainerService
            {
                Location                = this.Location,
                Tags                    = (this.Tag == null) ? null : this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value),
                AgentPoolProfiles       = this.AgentPoolProfile,
                OrchestratorProfile     = vOrchestratorProfile,
                CustomProfile           = vCustomProfile,
                ServicePrincipalProfile = vServicePrincipalProfile,
                MasterProfile           = vMasterProfile,
                WindowsProfile          = vWindowsProfile,
                LinuxProfile            = vLinuxProfile,
                DiagnosticsProfile      = vDiagnosticsProfile,
            };

            WriteObject(vContainerService);
        }