Class DeployMojo

  • All Implemented Interfaces:
    com.microsoft.azure.maven.auth.AuthConfiguration, com.microsoft.azure.maven.telemetry.TelemetryConfiguration, org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="deploy",
          defaultPhase=DEPLOY)
    public class DeployMojo
    extends AbstractFunctionMojo
    Deploy artifacts to target Azure Functions in Azure. If target Azure Functions doesn't exist, it will be created.
    • Constructor Detail

      • DeployMojo

        public DeployMojo()
    • Method Detail

      • getDeploymentType

        public com.microsoft.azure.common.appservice.DeploymentType getDeploymentType()
                                                                               throws com.microsoft.azure.common.exceptions.AzureExecutionException
        Overrides:
        getDeploymentType in class com.microsoft.azure.maven.AbstractAppServiceMojo
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException
      • doExecute

        protected void doExecute()
                          throws com.microsoft.azure.common.exceptions.AzureExecutionException
        Specified by:
        doExecute in class com.microsoft.azure.maven.AbstractAzureMojo
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException
      • deployArtifact

        private void deployArtifact​(com.microsoft.azure.common.deploytarget.DeployTarget deployTarget)
                             throws com.microsoft.azure.common.exceptions.AzureExecutionException,
                                    com.microsoft.azure.maven.auth.AzureAuthFailureException
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException
        com.microsoft.azure.maven.auth.AzureAuthFailureException
      • createOrUpdateResource

        protected com.microsoft.azure.management.appservice.WebAppBase createOrUpdateResource()
                                                                                       throws com.microsoft.azure.common.exceptions.AzureExecutionException,
                                                                                              com.microsoft.azure.maven.auth.AzureAuthFailureException
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException
        com.microsoft.azure.maven.auth.AzureAuthFailureException
      • createFunctionApp

        protected com.microsoft.azure.management.appservice.FunctionApp createFunctionApp​(com.microsoft.azure.common.function.handlers.runtime.FunctionRuntimeHandler runtimeHandler)
                                                                                   throws com.microsoft.azure.maven.auth.AzureAuthFailureException,
                                                                                          com.microsoft.azure.common.exceptions.AzureExecutionException
        Throws:
        com.microsoft.azure.maven.auth.AzureAuthFailureException
        com.microsoft.azure.common.exceptions.AzureExecutionException
      • updateFunctionApp

        protected com.microsoft.azure.management.appservice.FunctionApp updateFunctionApp​(com.microsoft.azure.management.appservice.FunctionApp app,
                                                                                          com.microsoft.azure.common.function.handlers.runtime.FunctionRuntimeHandler runtimeHandler)
                                                                                   throws com.microsoft.azure.maven.auth.AzureAuthFailureException,
                                                                                          com.microsoft.azure.common.exceptions.AzureExecutionException
        Throws:
        com.microsoft.azure.maven.auth.AzureAuthFailureException
        com.microsoft.azure.common.exceptions.AzureExecutionException
      • createDeploymentSlot

        protected com.microsoft.azure.management.appservice.FunctionDeploymentSlot createDeploymentSlot​(com.microsoft.azure.management.appservice.FunctionApp functionApp,
                                                                                                        com.microsoft.azure.common.function.handlers.runtime.FunctionRuntimeHandler runtimeHandler)
                                                                                                 throws com.microsoft.azure.common.exceptions.AzureExecutionException,
                                                                                                        com.microsoft.azure.maven.auth.AzureAuthFailureException
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException
        com.microsoft.azure.maven.auth.AzureAuthFailureException
      • updateDeploymentSlot

        protected com.microsoft.azure.management.appservice.FunctionDeploymentSlot updateDeploymentSlot​(com.microsoft.azure.management.appservice.FunctionDeploymentSlot deploymentSlot,
                                                                                                        com.microsoft.azure.common.function.handlers.runtime.FunctionRuntimeHandler runtimeHandler)
                                                                                                 throws com.microsoft.azure.maven.auth.AzureAuthFailureException,
                                                                                                        com.microsoft.azure.common.exceptions.AzureExecutionException
        Throws:
        com.microsoft.azure.maven.auth.AzureAuthFailureException
        com.microsoft.azure.common.exceptions.AzureExecutionException
      • listHTTPTriggerUrls

        protected void listHTTPTriggerUrls()
        List anonymous HTTP Triggers url after deployment
      • getFunctionRuntimeHandler

        protected com.microsoft.azure.common.function.handlers.runtime.FunctionRuntimeHandler getFunctionRuntimeHandler()
                                                                                                                 throws com.microsoft.azure.maven.auth.AzureAuthFailureException,
                                                                                                                        com.microsoft.azure.common.exceptions.AzureExecutionException
        Throws:
        com.microsoft.azure.maven.auth.AzureAuthFailureException
        com.microsoft.azure.common.exceptions.AzureExecutionException
      • validateServicePlanRuntime

        private void validateServicePlanRuntime​(com.microsoft.azure.common.appservice.OperatingSystemEnum os)
                                         throws com.microsoft.azure.common.exceptions.AzureExecutionException,
                                                com.microsoft.azure.maven.auth.AzureAuthFailureException
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException
        com.microsoft.azure.maven.auth.AzureAuthFailureException
      • getOsEnum

        protected com.microsoft.azure.common.appservice.OperatingSystemEnum getOsEnum()
                                                                               throws com.microsoft.azure.common.exceptions.AzureExecutionException
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException
      • getArtifactHandler

        protected com.microsoft.azure.common.handlers.ArtifactHandler getArtifactHandler()
                                                                                  throws com.microsoft.azure.common.exceptions.AzureExecutionException
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException
      • getDeploymentTypeByRuntime

        protected com.microsoft.azure.common.appservice.DeploymentType getDeploymentTypeByRuntime()
                                                                                           throws com.microsoft.azure.common.exceptions.AzureExecutionException
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException
      • isDedicatedPricingTier

        protected boolean isDedicatedPricingTier()
                                          throws com.microsoft.azure.common.exceptions.AzureExecutionException
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException
      • checkArtifactCompileVersion

        protected void checkArtifactCompileVersion()
                                            throws com.microsoft.azure.common.exceptions.AzureExecutionException
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException
      • parseConfiguration

        protected void parseConfiguration()
      • processAppSettingsWithDefaultValue

        public void processAppSettingsWithDefaultValue()
      • setDefaultAppSetting

        private void setDefaultAppSetting​(Map result,
                                          String settingName,
                                          String settingIsEmptyMessage,
                                          String settingValue)
      • setDefaultAppSetting

        private void setDefaultAppSetting​(Map result,
                                          String settingName,
                                          String settingIsEmptyMessage,
                                          String defaultValue,
                                          String warningMessage)
      • getFunctionExtensionVersion

        public com.microsoft.azure.common.function.configurations.FunctionExtensionVersion getFunctionExtensionVersion()
                                                                                                                throws com.microsoft.azure.common.exceptions.AzureExecutionException
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException
      • configureAppSettings

        protected void configureAppSettings​(java.util.function.Consumer<Map> withAppSettings,
                                            Map appSettings)
      • updateFunctionAppSettings

        private com.microsoft.azure.management.appservice.WebAppBase.Update updateFunctionAppSettings​(com.microsoft.azure.management.appservice.WebAppBase.Update update)
                                                                                               throws com.microsoft.azure.common.exceptions.AzureExecutionException,
                                                                                                      com.microsoft.azure.maven.auth.AzureAuthFailureException
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException
        com.microsoft.azure.maven.auth.AzureAuthFailureException
      • getArtifactToDeploy

        private File getArtifactToDeploy()
                                  throws com.microsoft.azure.common.exceptions.AzureExecutionException
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException
      • listFunctions

        private List<com.microsoft.azure.common.function.model.FunctionResource> listFunctions()
                                                                                        throws com.microsoft.azure.common.exceptions.AzureExecutionException,
                                                                                               com.microsoft.azure.maven.auth.AzureAuthFailureException,
                                                                                               InterruptedException
        Sync triggers and return function list of deployed function app Will retry when get empty result, the max retry times is LIST_TRIGGERS_MAX_RETRY
        Returns:
        List of functions in deployed function app
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException - Throw if get empty result after LIST_TRIGGERS_MAX_RETRY times retry
        com.microsoft.azure.maven.auth.AzureAuthFailureException - Throw if meet Authentication exception while getting Azure client or Function app
        InterruptedException - Throw when thread was interrupted while sleeping between retry
      • bindApplicationInsights

        private void bindApplicationInsights​(Map appSettings,
                                             boolean isCreation)
                                      throws com.microsoft.azure.common.exceptions.AzureExecutionException,
                                             com.microsoft.azure.maven.auth.AzureAuthFailureException
        Binding Function App with Application Insights Will follow the below sequence appInsightsKey -> appInsightsInstance -> Create New AI Instance (Function creation only)
        Parameters:
        appSettings - App settings map
        isCreation - Define the stage of function app, as we only create ai instance by default when create new function apps
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException - When there are conflicts in configuration or meet errors while finding/creating application insights instance
        com.microsoft.azure.maven.auth.AzureAuthFailureException
      • validateApplicationInsightsConfiguration

        private void validateApplicationInsightsConfiguration()
                                                       throws com.microsoft.azure.common.exceptions.AzureExecutionException
        Throws:
        com.microsoft.azure.common.exceptions.AzureExecutionException
      • isDeployToSlot

        private boolean isDeployToSlot()
      • getOrCreateApplicationInsights

        private com.microsoft.azure.management.applicationinsights.v2015_05_01.ApplicationInsightsComponent getOrCreateApplicationInsights​(boolean enableCreation)
                                                                                                                                    throws com.microsoft.azure.maven.auth.AzureAuthFailureException,
                                                                                                                                           com.microsoft.azure.common.exceptions.AzureExecutionException
        Throws:
        com.microsoft.azure.maven.auth.AzureAuthFailureException
        com.microsoft.azure.common.exceptions.AzureExecutionException
      • getApplicationInsights

        private com.microsoft.azure.management.applicationinsights.v2015_05_01.ApplicationInsightsComponent getApplicationInsights​(com.microsoft.azure.common.applicationinsights.ApplicationInsightsManager applicationInsightsManager,
                                                                                                                                   String appInsightsInstance)
      • createApplicationInsights

        private com.microsoft.azure.management.applicationinsights.v2015_05_01.ApplicationInsightsComponent createApplicationInsights​(com.microsoft.azure.common.applicationinsights.ApplicationInsightsManager applicationInsightsManager,
                                                                                                                                      String name)