Exemplo n.º 1
0
        private void Run()
        {
            // VirtualMachineProfile
            if (this.VirtualMachineScaleSet.VirtualMachineProfile == null)
            {
                this.VirtualMachineScaleSet.VirtualMachineProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetVMProfile();
            }

            // ExtensionProfile
            if (this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile == null)
            {
                this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtensionProfile();
            }

            // Extensions
            if (this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions == null)
            {
                this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions = new List <Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtension>();
            }

            var vExtensions = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtension();

            vExtensions.Name                    = this.MyInvocation.BoundParameters.ContainsKey("Name") ? this.Name : null;
            vExtensions.ForceUpdateTag          = this.MyInvocation.BoundParameters.ContainsKey("ForceUpdateTag") ? this.ForceUpdateTag : null;
            vExtensions.Publisher               = this.MyInvocation.BoundParameters.ContainsKey("Publisher") ? this.Publisher : null;
            vExtensions.Type                    = this.MyInvocation.BoundParameters.ContainsKey("Type") ? this.Type : null;
            vExtensions.TypeHandlerVersion      = this.MyInvocation.BoundParameters.ContainsKey("TypeHandlerVersion") ? this.TypeHandlerVersion : null;
            vExtensions.AutoUpgradeMinorVersion = this.MyInvocation.BoundParameters.ContainsKey("AutoUpgradeMinorVersion") ? this.AutoUpgradeMinorVersion : (bool?)null;
            vExtensions.Settings                = this.MyInvocation.BoundParameters.ContainsKey("Setting") ? this.Setting : null;
            vExtensions.ProtectedSettings       = this.MyInvocation.BoundParameters.ContainsKey("ProtectedSetting") ? this.ProtectedSetting : null;
            this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions.Add(vExtensions);
            WriteObject(this.VirtualMachineScaleSet);
        }
Exemplo n.º 2
0
        protected override void ProcessRecord()
        {
            // VirtualMachineProfile
            if (this.VirtualMachineScaleSet.VirtualMachineProfile == null)
            {
                this.VirtualMachineScaleSet.VirtualMachineProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetVMProfile();
            }

            // ExtensionProfile
            if (this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile == null)
            {
                this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtensionProfile();
            }

            // Extensions
            if (this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions == null)
            {
                this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions = new List <Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtension>();
            }

            var vExtensions = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtension();

            vExtensions.Name                    = this.Name;
            vExtensions.Publisher               = this.Publisher;
            vExtensions.Type                    = this.Type;
            vExtensions.TypeHandlerVersion      = this.TypeHandlerVersion;
            vExtensions.AutoUpgradeMinorVersion = this.AutoUpgradeMinorVersion;
            vExtensions.Settings                = this.Setting;
            vExtensions.ProtectedSettings       = this.ProtectedSetting;
            vExtensions.Id = this.Id;
            this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions.Add(vExtensions);
            WriteObject(this.VirtualMachineScaleSet);
        }
        private void Run()
        {
            WriteWarning("Add-AzureRmVmssExtension: A property of the output of this cmdlet will change in an upcoming breaking change release. " +
                         "The StorageAccountType property for a DataDisk will return Standard_LRS and Premium_LRS");

            // VirtualMachineProfile
            if (this.VirtualMachineScaleSet.VirtualMachineProfile == null)
            {
                this.VirtualMachineScaleSet.VirtualMachineProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetVMProfile();
            }

            // ExtensionProfile
            if (this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile == null)
            {
                this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtensionProfile();
            }

            // Extensions
            if (this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions == null)
            {
                this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions = new List <Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtension>();
            }

            var vExtensions = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtension();

            vExtensions.Name                    = this.MyInvocation.BoundParameters.ContainsKey("Name") ? this.Name : null;
            vExtensions.ForceUpdateTag          = this.MyInvocation.BoundParameters.ContainsKey("ForceUpdateTag") ? this.ForceUpdateTag : null;
            vExtensions.Publisher               = this.MyInvocation.BoundParameters.ContainsKey("Publisher") ? this.Publisher : null;
            vExtensions.Type                    = this.MyInvocation.BoundParameters.ContainsKey("Type") ? this.Type : null;
            vExtensions.TypeHandlerVersion      = this.MyInvocation.BoundParameters.ContainsKey("TypeHandlerVersion") ? this.TypeHandlerVersion : null;
            vExtensions.AutoUpgradeMinorVersion = this.MyInvocation.BoundParameters.ContainsKey("AutoUpgradeMinorVersion") ? this.AutoUpgradeMinorVersion : (bool?)null;
            vExtensions.Settings                = this.MyInvocation.BoundParameters.ContainsKey("Setting") ? this.Setting : null;
            vExtensions.ProtectedSettings       = this.MyInvocation.BoundParameters.ContainsKey("ProtectedSetting") ? this.ProtectedSetting : null;
            this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions.Add(vExtensions);
            WriteObject(this.VirtualMachineScaleSet);
        }
Exemplo n.º 4
0
        protected override void ProcessRecord()
        {
            if (ShouldProcess(this.VirtualMachineScaleSet.Name, Properties.Resources.AddVmssDiagnosticsExtensionAction))
            {
                // VirtualMachineProfile
                if (this.VirtualMachineScaleSet.VirtualMachineProfile == null)
                {
                    this.VirtualMachineScaleSet.VirtualMachineProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetVMProfile();
                }

                // ExtensionProfile
                if (this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile == null)
                {
                    this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtensionProfile();
                }

                // Extensions
                if (this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions == null)
                {
                    this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions = new List <Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtension>();
                }

                bool shouldContinue = true;

                // Warning if there's already a diagnostics extension.
                var extensions = this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions;
                if (extensions.Any(DiagnosticsHelper.IsDiagnosticsExtension))
                {
                    if (Force.IsPresent ||
                        ShouldContinue(Properties.Resources.DiagnosticsExtensionOverwrittingConfirmation, Properties.Resources.DiagnosticsExtensionOverwrittingCaption))
                    {
                        WriteWarning(Properties.Resources.DiagnosticsExtensionOverwriting);

                        // Remove all existing diagnostics extensions
                        this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions = extensions.Where(extension => !DiagnosticsHelper.IsDiagnosticsExtension(extension)).ToList();
                    }
                    else
                    {
                        shouldContinue = false;
                    }
                }

                if (shouldContinue)
                {
                    var storageClient = AzureSession.ClientFactory.CreateArmClient <StorageManagementClient>(DefaultProfile.Context, AzureEnvironment.Endpoint.ResourceManager);

                    // Parse configs, and auto fill incomplete parts
                    Tuple <Hashtable, Hashtable> settings = DiagnosticsHelper.GetConfigurationsFromFiles(this.SettingFilePath, this.ProtectedSettingFilePath, this.VirtualMachineScaleSet.Id, this, storageClient);

                    var newDiagnosticsExtension = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtension();

                    newDiagnosticsExtension.Name                    = this.Name;
                    newDiagnosticsExtension.Publisher               = DiagnosticsExtensionConstants.ExtensionPublisher;
                    newDiagnosticsExtension.Type                    = DiagnosticsExtensionConstants.ExtensionType;
                    newDiagnosticsExtension.TypeHandlerVersion      = this.TypeHandlerVersion;
                    newDiagnosticsExtension.AutoUpgradeMinorVersion = this.AutoUpgradeMinorVersion;
                    newDiagnosticsExtension.Settings                = settings.Item1;
                    newDiagnosticsExtension.ProtectedSettings       = settings.Item2;
                    this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions.Add(newDiagnosticsExtension);
                }
            }

            WriteObject(this.VirtualMachineScaleSet);
        }
        protected override void ProcessRecord()
        {
            // VirtualMachineProfile
            if (this.VirtualMachineScaleSet.VirtualMachineProfile == null)
            {
                this.VirtualMachineScaleSet.VirtualMachineProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetVMProfile();
            }

            // ExtensionProfile
            if (this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile == null)
            {
                this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtensionProfile();
            }

            // Extensions
            if (this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions == null)
            {
                this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions = new List<Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtension>();
            }

            var vExtensions = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtension();

            vExtensions.Name = this.Name;
            vExtensions.Publisher = this.Publisher;
            vExtensions.Type = this.Type;
            vExtensions.TypeHandlerVersion = this.TypeHandlerVersion;
            vExtensions.AutoUpgradeMinorVersion = this.AutoUpgradeMinorVersion;
            vExtensions.Settings = this.Setting;
            vExtensions.ProtectedSettings = this.ProtectedSetting;
            vExtensions.Id = this.Id;
            this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions.Add(vExtensions);
            WriteObject(this.VirtualMachineScaleSet);
        }
        protected override void ProcessRecord()
        {
            if (ShouldProcess(this.VirtualMachineScaleSet.Name, Properties.Resources.AddVmssDiagnosticsExtensionAction))
            {
                // VirtualMachineProfile
                if (this.VirtualMachineScaleSet.VirtualMachineProfile == null)
                {
                    this.VirtualMachineScaleSet.VirtualMachineProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetVMProfile();
                }

                // ExtensionProfile
                if (this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile == null)
                {
                    this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtensionProfile();
                }

                // Extensions
                if (this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions == null)
                {
                    this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions = new List<Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtension>();
                }

                bool shouldContinue = true;

                // Warning if there's already a diagnostics extension.
                var extensions = this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions;
                if (extensions.Any(DiagnosticsHelper.IsDiagnosticsExtension))
                {
                    if (Force.IsPresent
                        || ShouldContinue(Properties.Resources.DiagnosticsExtensionOverwrittingConfirmation, Properties.Resources.DiagnosticsExtensionOverwrittingCaption))
                    {
                        WriteWarning(Properties.Resources.DiagnosticsExtensionOverwriting);

                        // Remove all existing diagnostics extensions
                        this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions = extensions.Where(extension => !DiagnosticsHelper.IsDiagnosticsExtension(extension)).ToList();
                    }
                    else
                    {
                        shouldContinue = false;
                    }
                }

                if (shouldContinue)
                {
                    var storageClient = AzureSession.ClientFactory.CreateArmClient<StorageManagementClient>(DefaultProfile.Context, AzureEnvironment.Endpoint.ResourceManager);

                    // Parse configs, and auto fill incomplete parts
                    Tuple<Hashtable, Hashtable> settings = DiagnosticsHelper.GetConfigurationsFromFiles(this.SettingFilePath, this.ProtectedSettingFilePath, this.VirtualMachineScaleSet.Id, this, storageClient);

                    var newDiagnosticsExtension = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtension();

                    newDiagnosticsExtension.Name = this.Name;
                    newDiagnosticsExtension.Publisher = DiagnosticsExtensionConstants.ExtensionPublisher;
                    newDiagnosticsExtension.Type = DiagnosticsExtensionConstants.ExtensionType;
                    newDiagnosticsExtension.TypeHandlerVersion = this.TypeHandlerVersion;
                    newDiagnosticsExtension.AutoUpgradeMinorVersion = this.AutoUpgradeMinorVersion;
                    newDiagnosticsExtension.Settings = settings.Item1;
                    newDiagnosticsExtension.ProtectedSettings = settings.Item2;
                    this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions.Add(newDiagnosticsExtension);
                }
            }

            WriteObject(this.VirtualMachineScaleSet);
        }