use of com.microsoft.azure.plugin.functions.gradle.GradleFunctionContext in project azure-gradle-plugins by microsoft.
the class DeployTask method deploy.
@TaskAction
@AzureOperation(name = "functionapp.deploy_app", type = AzureOperation.Type.ACTION)
public void deploy() throws GradleException {
try {
ProxyManager.getInstance().applyProxy();
TelemetryAgent.getInstance().addDefaultProperty(PROXY, String.valueOf(ProxyManager.getInstance().isProxyEnabled()));
TelemetryAgent.getInstance().trackTaskStart(this.getClass());
final GradleFunctionContext ctx = new GradleFunctionContext(getProject(), this.getFunctionsExtension());
TelemetryAgent.getInstance().addDefaultProperties(ctx.getTelemetryProperties());
final DeployHandler deployHandler = new DeployHandler(ctx);
deployHandler.execute();
TelemetryAgent.getInstance().trackTaskSuccess(this.getClass());
} catch (final Exception e) {
AzureMessager.getMessager().error(e);
TelemetryAgent.getInstance().traceException(this.getClass(), e);
throw new GradleException(DEPLOY_FAILURE + e.getMessage(), e);
}
}
use of com.microsoft.azure.plugin.functions.gradle.GradleFunctionContext in project azure-gradle-plugins by microsoft.
the class LocalRunTask method exec.
@TaskAction
@Override
@AzureOperation(name = "functionapp.run", type = AzureOperation.Type.ACTION)
public void exec() {
try {
TelemetryAgent.getInstance().trackTaskStart(this.getClass());
final GradleFunctionContext ctx = new GradleFunctionContext(getProject(), this.getFunctionsExtension());
final String cliExec = FunctionCliResolver.resolveFunc();
if (StringUtils.isEmpty(cliExec)) {
throw new GradleException(FUNC_CORE_CLI_NOT_FOUND);
}
final String stagingFolder = ctx.getDeploymentStagingDirectoryPath();
FunctionUtils.checkStagingDirectory(stagingFolder);
if (BooleanUtils.isTrue(this.enableDebug) || StringUtils.isNotEmpty(ctx.getLocalDebugConfig())) {
this.commandLine(cliExec, "host", "start", "--language-worker", "--", getDebugJvmArgument(ctx.getLocalDebugConfig()));
} else {
this.commandLine(cliExec, "host", "start");
}
this.setWorkingDir(new File(stagingFolder));
this.setIgnoreExitValue(true);
super.exec();
final int code = this.getExecResult().getExitValue();
for (final Long validCode : CommandUtils.getValidReturnCodes()) {
if (validCode != null && validCode.intValue() == code) {
TelemetryAgent.getInstance().trackTaskSuccess(this.getClass());
return;
}
}
throw new GradleException(RUN_FUNCTIONS_FAILURE);
} catch (Exception e) {
TelemetryAgent.getInstance().traceException(this.getClass(), e);
throw new GradleException("Cannot run functions locally due to error:" + e.getMessage(), e);
}
}
use of com.microsoft.azure.plugin.functions.gradle.GradleFunctionContext in project azure-gradle-plugins by microsoft.
the class PackageTask method build.
@TaskAction
@AzureOperation(name = "functionapp.package", type = AzureOperation.Type.ACTION)
public void build() throws GradleException {
try {
TelemetryAgent.getInstance().trackTaskStart(this.getClass());
final GradleFunctionContext ctx = new GradleFunctionContext(getProject(), this.getFunctionsExtension());
TelemetryAgent.getInstance().addDefaultProperties(ctx.getTelemetryProperties());
final File stagingFolder = new File(ctx.getDeploymentStagingDirectoryPath());
// package task will start from a empty staging folder
if (stagingFolder.exists()) {
FileUtils.cleanDirectory(stagingFolder);
} else {
stagingFolder.mkdirs();
}
final PackageHandler packageHandler = new PackageHandler(ctx.getProject(), ctx.getDeploymentStagingDirectoryPath());
packageHandler.execute();
TelemetryAgent.getInstance().trackTaskSuccess(this.getClass());
} catch (Exception e) {
TelemetryAgent.getInstance().traceException(this.getClass(), e);
throw new GradleException(PACKAGE_FAILURE + e.getMessage(), e);
}
}
use of com.microsoft.azure.plugin.functions.gradle.GradleFunctionContext in project azure-gradle-plugins by microsoft.
the class PackageZipTask method buildZip.
@TaskAction
public void buildZip() throws GradleException, IOException {
try {
TelemetryAgent.getInstance().trackTaskStart(this.getClass());
final GradleFunctionContext ctx = new GradleFunctionContext(getProject(), this.getFunctionsExtension());
FunctionUtils.checkStagingDirectory(ctx.getDeploymentStagingDirectoryPath());
final File zipFile = new File(ctx.getDeploymentStagingDirectoryPath() + ".zip");
ZipUtil.pack(new File(ctx.getDeploymentStagingDirectoryPath()), zipFile);
ZipUtil.removeEntry(zipFile, PackageHandler.LOCAL_SETTINGS_JSON);
AzureMessager.getMessager().info("Build zip from staging folder successfully: " + zipFile.getAbsolutePath());
TelemetryAgent.getInstance().trackTaskSuccess(this.getClass());
} catch (Exception e) {
TelemetryAgent.getInstance().traceException(this.getClass(), e);
throw new GradleException(PACKAGE_ZIP_FAILURE + e.getMessage(), e);
}
}
Aggregations