Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails deploying azure function using azure cli auth type #2165

Open
pankajagrawal16 opened this issue Nov 7, 2022 · 12 comments
Open

Fails deploying azure function using azure cli auth type #2165

pankajagrawal16 opened this issue Nov 7, 2022 · 12 comments

Comments

@pankajagrawal16
Copy link

Plugin name and version

<plugin>
                    <groupId>com.microsoft.azure</groupId>
                    <artifactId>azure-functions-maven-plugin</artifactId>
                    <version>1.21.0</version>
                </plugin>

Plugin configuration in your pom.xml

  <plugin>
                <groupId>com.microsoft.azure</groupId>
                <artifactId>azure-functions-maven-plugin</artifactId>
        <configuration>
                    <resourceGroup>${functionResourceGroup}</resourceGroup>
                    <appName>${functionAppName}</appName>
                    <region>${functionAppRegion}</region>
                    <auth><type>azure_cli</type></auth>
                    <subscriptionId>subscription id</subscriptionId>
                    <appSettings>
                        <!-- Run Azure Function from package file by default -->
                        <property>
                            <name>WEBSITE_RUN_FROM_PACKAGE</name>
                            <value>1</value>
                        </property>
                        <property>
                            <name>FUNCTIONS_EXTENSION_VERSION</name>
                            <value>~4</value>
                        </property>
                        <property>
                            <name>FUNCTIONS_WORKER_RUNTIME</name>
                            <value>java</value>
                        </property>
                    </appSettings>
                </configuration>
                <executions>
                    <execution>
                        <id>package-functions</id>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Expected behavior

should deploy.

Actual behavior

Fails with below error

Caused by: com.microsoft.azure.toolkit.lib.auth.exception.AzureToolkitAuthenticationException: execute Azure Cli command 'az version --output json' failed due to error: Process exited with an error: 2 (Exit value: 2).
    at com.microsoft.azure.toolkit.lib.auth.util.AzureCliUtils.executeAzureCli (AzureCliUtils.java:99)
    at com.microsoft.azure.toolkit.lib.auth.util.AzureCliUtils.ensureMinimumCliVersion (AzureCliUtils.java:31)
    at com.microsoft.azure.toolkit.lib.auth.core.azurecli.AzureCliAccount.lambda$preLoginCheck$2 (AzureCliAccount.java:36)
    at reactor.core.publisher.MonoCallable.subscribe (MonoCallable.java:56)
    at reactor.core.publisher.Mono.subscribe (Mono.java:4150)
    at reactor.core.publisher.Mono.block (Mono.java:1702)

Steps to reproduce the problem

  • Login use az login and set subscription.
  • attempts to deploy
@adeabayyup
Copy link

I think it's a typo in your pom.xml. Instead of <auth><type>azure_cli</type></auth> use <authType>azure_cli</authType>

@pankajagrawal16
Copy link
Author

I think it's a typo in your pom.xml. Instead of <auth><type>azure_cli</type></auth> use <authType>azure_cli</authType>

Still fails with same error

@wangmingliang-ms
Copy link
Contributor

I think it's a typo in your pom.xml. Instead of <auth><type>azure_cli</type></auth> use <authType>azure_cli</authType>

Still fails with same error

what did you see when you run az version --output json directly in shell/terminal?

@pankajagrawal16
Copy link
Author

what did you see when you run az version --output json directly in shell/terminal?

{
  "azure-cli": "2.42.0",
  "azure-cli-core": "2.42.0",
  "azure-cli-telemetry": "1.0.8",
  "extensions": {
    "account": "0.2.5",
    "interactive": "0.4.5",
    "storage-preview": "0.8.3"
  }
}

@pankajagrawal16
Copy link
Author

Not sure why but I just tried once again, and this time it seems to work. Super weird. I don't recall doing any kind of changes etc

@pankajagrawal16
Copy link
Author

ok now it fails saying:

Caused by: com.microsoft.azure.toolkit.lib.auth.AzureToolkitAuthenticationException: execute Azure Cli command 'az account list --output json' failed due to error: Process exited with an error: 2 (Exit value: 2).
    at com.microsoft.azure.toolkit.lib.auth.cli.AzureCliUtils.executeAzureCli (AzureCliUtils.java:84)
    at com.microsoft.azure.toolkit.lib.auth.cli.AzureCliUtils.listSubscriptions (AzureCliUtils.java:59)
    at com.microsoft.azure.toolkit.lib.auth.cli.AzureCliAccount.loadSubscriptions (AzureCliAccount.java:55)
    at com.microsoft.azure.toolkit.lib.auth.Account.reloadSubscriptions (Account.java:146)
    at com.microsoft.azure.toolkit.lib.auth.Account.login (Account.java:96)
    at com.microsoft.azure.toolkit.lib.auth.AzureAccount.login (AzureAccount.java:124)
    at com.microsoft.azure.maven.AbstractAzureMojo.loginAzure (AbstractAzureMojo.java:365)
    at com.microsoft.azure.maven.AbstractAzureMojo.loginAzure (AbstractAzureMojo.java:347)
    at com.microsoft.azure.maven.appservice.AbstractAppServiceMojo.initAzureAppServiceClient (AbstractAppServiceMojo.java:150)
    at com.microsoft.azure.maven.function.DeployMojo.d

@pankajagrawal16
Copy link
Author

Bit more investigation, it seems to fail only when attempting to deploy via WSL2 terminal . Seems to work when deploying via powershell terminal.

Why would that be?

@wangmingliang-ms
Copy link
Contributor

wangmingliang-ms commented Nov 14, 2022

thanks for your investigation, we didn't set any restrictions on WSL2, we'll investigate what is wrong.
does both az account list --output json and az version --output json works well in your WSL2 terminal?

@pankajagrawal16
Copy link
Author

thanks for your investigation, we didn't set any restrictions on WSL2, we'll investigate what is wrong. does both az account list --output json and az version --output json works well in your WSL2 terminal?

Yes both command works properly when run directly on wsl2 terminal and gives output

@jleonelion
Copy link

Up vote. I also have this problem.

wangmingliang-ms added a commit that referenced this issue Dec 12, 2022
#2165: Fails deploying azure function using azure cli auth type
@wangmingliang-ms
Copy link
Contributor

@jleonelion @pankajagrawal16 thanks for your report, this bug should be fixed by this PR: #2183.
the fix would be included in the next release v1.23.0

@pankajagrawal16
Copy link
Author

Nice @wangmingliang-ms ! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants