Пример #1
0
        protected override void OnProcessRecord()
        {
            string whatIfMessage  = this.ShouldExecuteWhatIf() ? this.ExecuteWhatIf() : null;
            string warningMessage = $"{Environment.NewLine}{ProjectResources.ConfirmDeploymentMessage}";
            string captionMessage = $"{(char)27}[1A{Color.Reset}{whatIfMessage}"; // {(char)27}[1A for cursor up.

            if (ShouldProcess(whatIfMessage, warningMessage, captionMessage))
            {
                var parameters = new PSDeploymentCmdletParameters()
                {
                    ScopeType               = DeploymentScopeType.Subscription,
                    Location                = Location,
                    DeploymentName          = Name,
                    DeploymentMode          = DeploymentMode.Incremental,
                    TemplateFile            = TemplateUri ?? this.TryResolvePath(TemplateFile),
                    TemplateObject          = TemplateObject,
                    TemplateParameterObject = GetTemplateParameterObject(TemplateParameterObject),
                    ParameterUri            = TemplateParameterUri,
                    DeploymentDebugLogLevel = GetDeploymentDebugLogLevel(DeploymentDebugLogLevel),
                    Tags = TagsHelper.ConvertToTagsDictionary(Tag)
                };

                if (!string.IsNullOrEmpty(parameters.DeploymentDebugLogLevel))
                {
                    WriteWarning(ProjectResources.WarnOnDeploymentDebugSetting);
                }
                WriteObject(ResourceManagerSdkClient.ExecuteDeployment(parameters));
            }
        }
Пример #2
0
        private void ExecuteDeployment()
        {
            if (RollbackToLastDeployment && !string.IsNullOrEmpty(RollBackDeploymentName))
            {
                WriteExceptionError(new ArgumentException(ProjectResources.InvalidRollbackParameters));
            }

            var parameters = new PSDeploymentCmdletParameters()
            {
                ScopeType               = DeploymentScopeType.ResourceGroup,
                ResourceGroupName       = ResourceGroupName,
                DeploymentName          = Name,
                DeploymentMode          = Mode,
                TemplateFile            = TemplateUri ?? this.TryResolvePath(TemplateFile),
                TemplateObject          = TemplateObject,
                TemplateParameterObject = GetTemplateParameterObject(TemplateParameterObject),
                ParameterUri            = TemplateParameterUri,
                DeploymentDebugLogLevel = GetDeploymentDebugLogLevel(DeploymentDebugLogLevel),
                Tags = TagsHelper.ConvertToTagsDictionary(Tag),
                OnErrorDeployment = RollbackToLastDeployment || !string.IsNullOrEmpty(RollBackDeploymentName)
                    ? new OnErrorDeployment
                {
                    Type           = RollbackToLastDeployment ? OnErrorDeploymentType.LastSuccessful : OnErrorDeploymentType.SpecificDeployment,
                    DeploymentName = RollbackToLastDeployment ? null : RollBackDeploymentName
                }
                    : null
            };

            if (!string.IsNullOrEmpty(parameters.DeploymentDebugLogLevel))
            {
                WriteWarning(ProjectResources.WarnOnDeploymentDebugSetting);
            }
            WriteObject(ResourceManagerSdkClient.ExecuteResourceGroupDeployment(parameters));
        }
        protected override void OnProcessRecord()
        {
            var parameters = new PSDeploymentCmdletParameters()
            {
                ScopeType               = DeploymentScopeType.Tenant,
                Location                = this.Location,
                DeploymentName          = this.Name,
                DeploymentMode          = DeploymentMode.Incremental,
                TemplateFile            = TemplateUri ?? this.TryResolvePath(TemplateFile),
                TemplateObject          = TemplateObject,
                TemplateParameterObject = GetTemplateParameterObject(TemplateParameterObject),
                ParameterUri            = TemplateParameterUri,
                DeploymentDebugLogLevel = GetDeploymentDebugLogLevel(DeploymentDebugLogLevel),
                Tags = TagsHelper.ConvertToTagsDictionary(Tag)
            };

            if (!string.IsNullOrEmpty(parameters.DeploymentDebugLogLevel))
            {
                WriteWarning(ProjectResources.WarnOnDeploymentDebugSetting);
            }
            WriteObject(ResourceManagerSdkClient.ExecuteDeployment(parameters));
        }