in src/iotEdgeExplorer.ts [182:229]
private async getDeploymentJson(filePath: string): Promise<string> {
if (!filePath) {
const filePathUri: vscode.Uri[] = await vscode.window.showOpenDialog({
openLabel: "Select Edge Deployment Manifest",
filters: {
JSON: ["json"],
},
defaultUri: Utility.getDefaultPath(),
});
if (!filePathUri) {
return "";
}
filePath = filePathUri[0].fsPath;
}
if (path.basename(filePath).endsWith(".template.json")) {
vscode.window.showWarningMessage("Please select deployment manifest file under 'config' folder for deployment.");
return "";
}
let content = stripJsonComments(fs.readFileSync(filePath, "utf8"));
try {
const contentJson = JSON.parse(content);
// Backward compatibility for old schema using 'moduleContent'
if (!contentJson.modulesContent && contentJson.moduleContent) {
contentJson.modulesContent = contentJson.moduleContent;
delete contentJson.moduleContent;
}
try {
const isValid = await this.isValidDeploymentJsonSchema(contentJson)
&& this.isValidCreateOptions(contentJson.modulesContent.$edgeAgent["properties.desired"]);
if (!isValid) {
return "";
}
} catch (error) {
TelemetryClient.sendEvent(Constants.IoTHubAIValidateJsonSchemaEvent, { [Constants.errorProperties.Message]: error.message });
}
content = JSON.stringify(contentJson, null, 2);
} catch (error) {
vscode.window.showErrorMessage("Failed to parse deployment manifest: " + error.toString());
return "";
}
return content;
}