Repository: microsoft/azure-maven-plugins
Issue: Azure Function Deployment Fails when setting Key Vault access to Function

### Plugin name and version
    azure-functions-maven-plugin:1.14.1

### Plugin configuration in your `pom.xml`

             <plugin>
                <groupId>com.microsoft.azure</groupId>
                <artifactId>azure-functions-maven-plugin</artifactId>
                <version>1.14.1</version>
                <configuration>
                    <appName>${functionAppName}</appName>
                    <resourceGroup>java-functions-group</resourceGroup>
                    <appServicePlanName>java-functions-app-service-plan</appServicePlanName>
                    <region>westus</region>
                    <runtime>
                        <os>windows</os>
                        <javaVersion>8</javaVersion>
                    </runtime>
                    <appSettings>
                        <property>
                            <name>FUNCTIONS_EXTENSION_VERSION</name>
                            <value>~3</value>
                        </property>
                    </appSettings>
                </configuration>
                <executions>
                    <execution>
                        <id>package-functions</id>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

### Expected behavior

Deploy Function to Azure Functions

### Actual behavior

     [ERROR] Failed to execute goal com.microsoft.azure:azure-functions-maven-plugin:1.14.1:deploy (default-cli) on project purchaselimitloader: deploy to Azure Function App with resource creation or updating: Invalid connection string. -> [Help 1]
     org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.microsoft.azure:azure-functions-maven-plugin:1.14.1:deploy (default-cli) on project purchaselimitloader: deploy to Azure Function App with resource creation or updating
         at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
         at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
         at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
         at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
         at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
         at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
         at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
         at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
         at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
         at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
         at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
         at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke (Method.java:567)
         at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
         at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
         at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
         at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
         at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
     Caused by: org.apache.maven.plugin.MojoExecutionException: deploy to Azure Function App with resource creation or updating
         at com.microsoft.azure.maven.AbstractAzureMojo.onMojoError (AbstractAzureMojo.java:575)
         at com.microsoft.azure.maven.AbstractAzureMojo.execute (AbstractAzureMojo.java:495)
         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
         at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
         at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
         at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
         at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
         at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
         at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
         at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
         at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
         at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
         at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
         at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
         at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke (Method.java:567)
         at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
         at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
         at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
         at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
         at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
     Caused by: com.microsoft.azure.toolkit.lib.common.operation.AzureOperationException: deploy to Azure Function App with resource creation or updating
         at com.microsoft.azure.toolkit.lib.common.operation.AzureOperationAspect.afterThrowing (AzureOperationAspect.java:81)
         at com.microsoft.azure.maven.function.DeployMojo.doExecute (DeployMojo.java:87)
         at com.microsoft.azure.maven.AbstractAzureMojo.execute (AbstractAzureMojo.java:490)
         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
         at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
         at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
         at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
         at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
         at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
         at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
         at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
         at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
         at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
         at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
         at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
         at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke (Method.java:567)
         at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
         at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
         at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
         at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
         at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
     Caused by: java.lang.IllegalArgumentException: Invalid connection string.
         at com.microsoft.azure.storage.CloudStorageAccount.parse (CloudStorageAccount.java:290)
         at com.microsoft.azure.toolkit.lib.appservice.service.impl.deploy.DeployUtils.lambda$getCloudStorageAccount$1 (DeployUtils.java:38)
         at java.util.Optional.map (Optional.java:258)
         at com.microsoft.azure.toolkit.lib.appservice.service.impl.deploy.DeployUtils.getCloudStorageAccount (DeployUtils.java:36)
         at com.microsoft.azure.toolkit.lib.appservice.service.impl.deploy.RunFromBlobFunctionDeployHandler.deploy (RunFromBlobFunctionDeployHandler.java:35)
         at com.microsoft.azure.toolkit.lib.appservice.service.impl.FunctionAppBase.deploy (FunctionAppBase.java:48)
         at com.microsoft.azure.toolkit.lib.appservice.service.impl.FunctionAppBase.deploy (FunctionAppBase.java:43)
         at com.microsoft.azure.toolkit.lib.appservice.task.DeployFunctionAppTask.deployArtifact (DeployFunctionAppTask.java:95)
         at com.microsoft.azure.toolkit.lib.appservice.task.DeployFunctionAppTask.execute (DeployFunctionAppTask.java:82)
         at com.microsoft.azure.maven.function.DeployMojo.deployArtifact (DeployMojo.java:183)
         at com.microsoft.azure.maven.function.DeployMojo.doExecute (DeployMojo.java:85)
         at com.microsoft.azure.maven.AbstractAzureMojo.execute (AbstractAzureMojo.java:490)
         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
         at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
         at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
         at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
         at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
         at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
         at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
         at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
         at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
         at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
         at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
         at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
         at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke (Method.java:567)
         at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
         at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
         at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
         at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
         at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
     [ERROR] 
     [ERROR] 
     [ERROR] For more information about the errors and possible solutions, please read the following articles:
     [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
     
### Steps to reproduce the problem

1. Deploy Function.
2. Grant Key Vault access to Function deployed.
3. Re-deploy the Function again.


Changed files:
azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/java/com/microsoft/azure/toolkit/lib/appservice/service/impl/deploy/DeployUtils.java

diff --git a/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/java/com/microsoft/azure/toolkit/lib/appservice/service/impl/deploy/DeployUtils.java b/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/java/com/microsoft/azure/toolkit/lib/appservice/service/impl/deploy/DeployUtils.java
index 78ad383c7..e27060bba 100644
--- a/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/java/com/microsoft/azure/toolkit/lib/appservice/service/impl/deploy/DeployUtils.java
+++ b/azure-toolkit-libs/azure-toolkit-appservice-lib/src/main/java/com/microsoft/azure/toolkit/lib/appservice/service/impl/deploy/DeployUtils.java
@@ -4,7 +4,6 @@
  */
 package com.microsoft.azure.toolkit.lib.appservice.service.impl.deploy;
 
-import com.azure.resourcemanager.appservice.models.AppSetting;
 import com.azure.resourcemanager.appservice.models.FunctionApp;
 import com.azure.resourcemanager.appservice.models.FunctionDeploymentSlot;
 import com.azure.resourcemanager.appservice.models.WebAppBase;
@@ -14,7 +13,6 @@ import org.apache.commons.lang3.StringUtils;
 
 import java.net.URISyntaxException;
 import java.security.InvalidKeyException;
-import java.util.Map;
 import java.util.Optional;
 
 class DeployUtils {
@@ -28,10 +26,9 @@ class DeployUtils {
      * @return StorageAccount specified in AzureWebJobsStorage
      */
     static CloudStorageAccount getCloudStorageAccount(final WebAppBase functionApp) {
-        final Map<String, AppSetting> settingsMap = functionApp.getAppSettings();
-        return Optional.ofNullable(settingsMap)
+        // Call functionApp.getSiteAppSettings() to get the app settings with key vault reference
+        return Optional.ofNullable(functionApp.getSiteAppSettings())
                 .map(map -> map.get(INTERNAL_STORAGE_KEY))
-                .map(AppSetting::value)
                 .filter(StringUtils::isNotEmpty)
                 .map(key -> {
                     try {