public override void ExecuteCmdlet() { const string blueprintFileName = "Blueprint"; // Get serialized blueprint definition string serializedDefinition = BlueprintClient.GetBlueprintDefinitionJsonFromObject(Blueprint, Version); var resolvedPath = ResolveUserPath(OutputPath); var blueprintFolderPath = Path.Combine(resolvedPath, Blueprint.Name); // if directory exists, let's ask if we can clean contents of it. If directory doesn't exist, we'll create one. this.ConfirmAction( this.Force || !AzureSession.Instance.DataStore.DirectoryExists(blueprintFolderPath), string.Format(Resources.DeleteBlueprintFolderContentsProcessString, Blueprint.Name), Resources.DeleteBlueprintFolderContentsContinueMessage, blueprintFolderPath, () => CreateFolderIfNotExist(resolvedPath, Blueprint.Name) ); var blueprintJsonFilePath = Path.Combine(blueprintFolderPath, $"{blueprintFileName}.json"); AzureSession.Instance.DataStore.WriteFile(blueprintJsonFilePath, serializedDefinition); var artifacts = BlueprintClient.ListArtifacts(Blueprint.Scope, Blueprint.Name, Version); if (artifacts != null && artifacts.Any()) { // Get serialized artifacts from this blueprint and write them to disk var artifactsPath = CreateFolderIfNotExist(blueprintFolderPath, "Artifacts"); foreach (var artifact in artifacts) { string serializedArtifact = BlueprintClient.GetBlueprintArtifactJsonFromObject(Blueprint.Scope, Blueprint.Name, artifact, Version); var artifactFilePath = Path.Combine(artifactsPath, artifact.Name + ".json"); AzureSession.Instance.DataStore.WriteFile(artifactFilePath, serializedArtifact); } } if (PassThru.IsPresent) { WriteObject(true); } }
public override void ExecuteCmdlet() { // Get serialized blueprint and write it to disk string serializedDefinition = BlueprintClient.GetBlueprintDefinitionJsonFromObject(Blueprint, Version); var blueprintFolderPath = CreateFolderIfNotExist(OutputPath, Blueprint.Name); var blueprintJsonFilePath = Path.Combine(blueprintFolderPath, $"{Blueprint.Name}.json"); this.ConfirmAction( this.Force || !AzureSession.Instance.DataStore.FileExists(blueprintJsonFilePath), string.Format(Resources.OverwriteExistingOutputFileProcessMessage, Blueprint.Name), Resources.OverwriteExistingOutputFileContinueMessage, blueprintJsonFilePath, () => AzureSession.Instance.DataStore.WriteFile(blueprintJsonFilePath, serializedDefinition) ); // Get serialized artifacts from this blueprint and write them to disk var artifactsPath = CreateFolderIfNotExist(blueprintFolderPath, "Artifacts"); var artifacts = BlueprintClient.ListArtifacts(Blueprint.Scope, Blueprint.Name, Version); foreach (var artifact in artifacts) { string serializedArtifact = BlueprintClient.GetBlueprintArtifactJsonFromObject(Blueprint.Scope, Blueprint.Name, artifact, Version); var artifactFilePath = Path.Combine(artifactsPath, artifact.Name + ".json"); this.ConfirmAction( this.Force || !AzureSession.Instance.DataStore.FileExists(artifactFilePath), string.Format(Resources.OverwriteExistingOutputFileProcessMessage, artifact.Name), Resources.OverwriteExistingOutputFileContinueMessage, artifactFilePath, () => AzureSession.Instance.DataStore.WriteFile(artifactFilePath, serializedArtifact) ); } if (PassThru.IsPresent) { WriteObject(true); } }