Exemplo n.º 1
0
        /// <summary>
        /// Executes the cmdlet.
        /// </summary>
        protected override void OnProcessRecord()
        {
            base.OnProcessRecord();

            var deploymentName = !string.IsNullOrEmpty(this.DeploymentName) ? this.DeploymentName : this.DeploymentObject.DeploymentName;

            if (ShouldProcess(deploymentName, VerbsData.Save))
            {
                var template = ResourceManagerSdkClient.GetDeploymentTemplateAtSubscrpitionScope(deploymentName);

                string path = FileUtility.SaveTemplateFile(
                    templateName: deploymentName,
                    contents: template,
                    outputPath:
                    string.IsNullOrEmpty(this.Path)
                            ? System.IO.Path.Combine(CurrentPath(), deploymentName)
                            : this.TryResolvePath(this.Path),
                    overwrite: this.Force,
                    shouldContinue: ShouldContinue);

                WriteObject(new PSTemplatePath()
                {
                    Path = path
                });
            }
        }