Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
        public override void ExecuteCmdlet()
        {
            this.ConfirmAction(
                this.Force,
                string.Format(ProjectResources.ConfirmOnCompleteDeploymentMode, this.ResourceGroupName),
                ProjectResources.CreateDeployment,
                ResourceGroupName,
                () =>
            {
                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),
                    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));
            },
                () => this.Mode == DeploymentMode.Complete);
        }