Search in sources :

Example 1 with FunctionDeployType

use of com.microsoft.azure.toolkit.lib.appservice.model.FunctionDeployType in project azure-tools-for-java by Microsoft.

the class FunctionAppService method deployFunctionApp.

public void deployFunctionApp(final IFunctionApp functionApp, final File stagingFolder) throws IOException {
    AzureMessager.getMessager().info(DEPLOY_START);
    final FunctionDeployType deployType = getDeployType(functionApp);
    AzureTelemetry.getActionContext().setProperty(DEPLOYMENT_TYPE, deployType.name());
    functionApp.deploy(packageStagingDirectory(stagingFolder), deployType);
    if (!StringUtils.equalsIgnoreCase(functionApp.state(), RUNNING)) {
        functionApp.start();
    }
    final String resourceUrl = String.format(PORTAL_URL_PATTERN, IdentityAzureManager.getInstance().getPortalUrl(), functionApp.id());
    AzureMessager.getMessager().info(String.format(DEPLOY_FINISH, resourceUrl));
}
Also used : FunctionDeployType(com.microsoft.azure.toolkit.lib.appservice.model.FunctionDeployType)

Example 2 with FunctionDeployType

use of com.microsoft.azure.toolkit.lib.appservice.model.FunctionDeployType in project azure-gradle-plugins by microsoft.

the class DeployHandler method deployArtifact.

private void deployArtifact(@Nonnull final FunctionAppBase<?, ?, ?> target) {
    final boolean isDockerRuntime = Optional.ofNullable(target.getRuntime()).map(Runtime::isDocker).orElse(false);
    if (isDockerRuntime) {
        AzureMessager.getMessager().info(SKIP_DEPLOYMENT_FOR_DOCKER_APP_SERVICE);
        return;
    }
    AzureMessager.getMessager().info(DEPLOY_START);
    String deploymentType = ctx.getDeploymentType();
    FunctionDeployType deployType;
    try {
        deployType = StringUtils.isEmpty(deploymentType) ? null : FunctionDeployType.fromString(deploymentType);
    } catch (AzureToolkitRuntimeException ex) {
        throw new AzureToolkitRuntimeException(UNKNOWN_DEPLOYMENT_TYPE, ex);
    }
    // For ftp deploy, we need to upload entire staging directory not the zipped package
    final File file = deployType == FunctionDeployType.FTP ? new File(ctx.getDeploymentStagingDirectoryPath()) : packageStagingDirectory();
    final RunnableWithException deployRunnable = deployType == null ? () -> target.deploy(file) : () -> target.deploy(file, deployType);
    executeWithTimeRecorder(deployRunnable, DEPLOY);
    // todo: check function status after deployment
    if (!target.getFormalStatus().isRunning()) {
        target.start();
    }
    AzureMessager.getMessager().info(String.format(DEPLOY_FINISH, getResourcePortalUrl(target.getId())));
}
Also used : AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) File(java.io.File) FunctionDeployType(com.microsoft.azure.toolkit.lib.appservice.model.FunctionDeployType)

Example 3 with FunctionDeployType

use of com.microsoft.azure.toolkit.lib.appservice.model.FunctionDeployType in project azure-maven-plugins by microsoft.

the class DeployMojo method deployArtifact.

private void deployArtifact(final IFunctionAppBase<?> target) {
    final File file = new File(getDeploymentStagingDirectoryPath());
    final FunctionDeployType type = StringUtils.isEmpty(deploymentType) ? null : FunctionDeployType.fromString(deploymentType);
    new DeployFunctionAppTask(target, file, type).execute();
}
Also used : File(java.io.File) FunctionDeployType(com.microsoft.azure.toolkit.lib.appservice.model.FunctionDeployType) DeployFunctionAppTask(com.microsoft.azure.toolkit.lib.appservice.task.DeployFunctionAppTask)

Example 4 with FunctionDeployType

use of com.microsoft.azure.toolkit.lib.appservice.model.FunctionDeployType in project azure-tools-for-java by microsoft.

the class FunctionAppService method deployFunctionApp.

public void deployFunctionApp(final IFunctionApp functionApp, final File stagingFolder) throws IOException {
    AzureMessager.getMessager().info(DEPLOY_START);
    final FunctionDeployType deployType = getDeployType(functionApp);
    AzureTelemetry.getActionContext().setProperty(DEPLOYMENT_TYPE, deployType.name());
    functionApp.deploy(packageStagingDirectory(stagingFolder), deployType);
    if (!StringUtils.equalsIgnoreCase(functionApp.state(), RUNNING)) {
        functionApp.start();
    }
    final String resourceUrl = String.format(PORTAL_URL_PATTERN, IdentityAzureManager.getInstance().getPortalUrl(), functionApp.id());
    AzureMessager.getMessager().info(String.format(DEPLOY_FINISH, resourceUrl));
}
Also used : FunctionDeployType(com.microsoft.azure.toolkit.lib.appservice.model.FunctionDeployType)

Example 5 with FunctionDeployType

use of com.microsoft.azure.toolkit.lib.appservice.model.FunctionDeployType in project azure-gradle-plugins by microsoft.

the class DeployHandler method deployArtifact.

private void deployArtifact(IFunctionAppBase target) throws AzureExecutionException {
    if (target.getRuntime().isDocker()) {
        AzureMessager.getMessager().info(SKIP_DEPLOYMENT_FOR_DOCKER_APP_SERVICE);
        return;
    }
    AzureMessager.getMessager().info(DEPLOY_START);
    String deploymentType = ctx.getDeploymentType();
    FunctionDeployType deployType;
    try {
        deployType = StringUtils.isEmpty(deploymentType) ? null : FunctionDeployType.fromString(deploymentType);
    } catch (AzureToolkitRuntimeException ex) {
        throw new AzureExecutionException(UNKNOWN_DEPLOYMENT_TYPE);
    }
    // For ftp deploy, we need to upload entire staging directory not the zipped package
    final File file = deployType == FunctionDeployType.FTP ? new File(ctx.getDeploymentStagingDirectoryPath()) : packageStagingDirectory();
    final RunnableWithException deployRunnable = deployType == null ? () -> target.deploy(file) : () -> target.deploy(file, deployType);
    executeWithTimeRecorder(deployRunnable, DEPLOY);
    // todo: check function status after deployment
    if (!StringUtils.equalsIgnoreCase(target.state(), RUNNING)) {
        target.start();
    }
    AzureMessager.getMessager().info(String.format(DEPLOY_FINISH, getResourcePortalUrl(target.id())));
}
Also used : AzureExecutionException(com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) File(java.io.File) FunctionDeployType(com.microsoft.azure.toolkit.lib.appservice.model.FunctionDeployType)

Aggregations

FunctionDeployType (com.microsoft.azure.toolkit.lib.appservice.model.FunctionDeployType)5 File (java.io.File)3 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)2 AzureToolkitRuntimeException (com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException)2 DeployFunctionAppTask (com.microsoft.azure.toolkit.lib.appservice.task.DeployFunctionAppTask)1 AzureExecutionException (com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException)1