sleeveforarm
Version:
Making Azure Easy
83 lines • 3.91 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const Path = require("path");
const applicationInsights_1 = require("./applicationInsights");
const CommonUtilities = require("./common-utilities");
const data = require("./data");
const promiseGate_1 = require("./promiseGate");
class BaseDeployApplicationInsightsInfrastructure {
constructor(instrumentationKey) {
this.instrumentationKey = instrumentationKey;
}
getInstrumentationKey() {
return this.instrumentationKey;
}
}
exports.BaseDeployApplicationInsightsInfrastructure = BaseDeployApplicationInsightsInfrastructure;
class ApplicationInsightsInfrastructure extends applicationInsights_1.default {
constructor() {
super(...arguments);
this.promiseGate = new promiseGate_1.default();
}
initialize(resource, targetDirectoryPath) {
super.initialize(resource, targetDirectoryPath);
if (resource !== null) {
Object.assign(this, resource);
}
return this;
}
setup() {
return __awaiter(this, void 0, void 0, function* () {
return yield ApplicationInsightsInfrastructure
.internalSetup(__filename, this.targetDirectoryPath, data.data.ApplicationInsightsLength);
});
}
hydrate(resourcesInEnvironment, deploymentType) {
const _super = name => super[name];
return __awaiter(this, void 0, void 0, function* () {
yield _super("hydrate").call(this, resourcesInEnvironment, deploymentType);
if (this.appInsightsFullName === undefined) {
this.appInsightsFullName = this.resourceGroup.resourceGroupName +
this.baseName;
}
return this;
});
}
deployResource() {
return __awaiter(this, void 0, void 0, function* () {
try {
const templateFilePath = Path.join(__dirname, "createAppInsightsARM.json");
yield this.resourceGroup.getBaseDeployClassInstance();
yield CommonUtilities.runAzCommand(`az group deployment create --name ${this.appInsightsFullName} \
--resource-group ${this.resourceGroup.resourceGroupName} \
--template-file ${templateFilePath} \
--parameters appName=${this.appInsightsFullName}`);
const properties = yield CommonUtilities.runAzCommand(`az resource show --name ${this.appInsightsFullName} \
--resource-group ${this.resourceGroup.resourceGroupName} \
--resource-type Microsoft.Insights/components`);
const instrumentationKey = properties.properties.InstrumentationKey;
this.promiseGate.openGateSuccess(new BaseDeployApplicationInsightsInfrastructure(instrumentationKey));
return this;
}
catch (err) {
this.promiseGate.openGateError(err);
throw err;
}
});
}
getBaseDeployClassInstance() {
return this.promiseGate.promise.then(function (baseClass) {
return baseClass;
});
}
}
exports.ApplicationInsightsInfrastructure = ApplicationInsightsInfrastructure;
//# sourceMappingURL=applicationInsightsInfrastructure.js.map