intellij IDEA + System.Net.Http. HTTP+发出从暂存文件夹运行函数CLI命令

klh5stk1  于 9个月前  发布在  IntelliJ IDEA
关注(0)|答案(1)|浏览(60)

我正在使用Azure Functions应用程序intellij idea。从昨天开始,我一直在努力解决以下问题:

[2023-10-05T12:18:02.170Z] A host error has occurred during startup operation '7ab97efe-26f0-49bd-a6c9-53decba6c71b'.
[2023-10-05T12:18:02.170Z] Microsoft.Azure.WebJobs.Extensions.Http: Could not load file or assembly 'System.Net.Http.Formatting, Version=5.2.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Value cannot be null. (Parameter 'provider')
[2023-10-05T12:18:02.197Z] Host startup operation has been canceled
Failed to run function CLI command from staging folder(azure-functions3169719571234745861). Value cannot be null. (Parameter 'provider').

我做了这些步骤:

  • Java版本在项目中的任何地方都是正确的。
  • 删除了所有Azure Functions Core Tool并升级到最新版本-不工作。
  • 删除此文件夹C:\Users\me.azure-functions-core-tools - not worked.
  • 删除所有版本的intellij 2021并安装最新的2023.2.2版本-不工作。
  • 运行mvn clean package或mvn clean insall -不起作用。
  • 删除.intellij文件夹,然后重新加载-不工作。
  • 安装VS Code并运行项目-不工作
  • 已尝试使用CLI -不起作用

同样的问题,我到处都有。
请让我知道是否有任何其他设置可以让我在intellij中使用Azure Functions。

nhaq1z21

nhaq1z211#

  • 这主要是由于Azure功能核心工具的问题。
  • 虽然您已升级Azure功能核心工具,但请尝试完全卸载功能核心工具,然后重新安装。
1. npm ls -g azure-functions-core-tools
2. npm uninstall -g func
3. npm install -g azure-functions-core-tools --unsafe-prem true

  • JavaMaven
  • 删除项目的bin文件夹,然后清理并重建应用程序。
  • 确保您在pom.xml中具有所有兼容版本所需的依赖项:
    我的示例Http Azure函数的Pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>samplehttpfunction</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Azure Java Functions</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <azure.functions.maven.plugin.version>1.24.0</azure.functions.maven.plugin.version>
        <azure.functions.java.library.version>3.0.0</azure.functions.java.library.version>
        <functionAppName>samplehttpfunction-1696583393512</functionAppName>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.microsoft.azure.functions</groupId>
            <artifactId>azure-functions-java-library</artifactId>
            <version>${azure.functions.java.library.version}</version>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.4.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>2.23.4</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.microsoft.azure</groupId>
                <artifactId>azure-functions-maven-plugin</artifactId>
                <version>${azure.functions.maven.plugin.version}</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>~4</value>
                        </property>
                    </appSettings>
                </configuration>
                <executions>
                    <execution>
                        <id>package-functions</id>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>obj</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

local.settings.json:

{  
"IsEncrypted": false,  
"Values": {  
"AzureWebJobsStorage": "usedevelopmentstorage=true",  
"FUNCTIONS_WORKER_RUNTIME": "java"  
}  
}
    • 如果问题仍然存在,请尝试创建新的示例Azure函数,并检查是否出现相同的错误。
      参考文献:

https://github.com/Azure/azure-functions-core-tools/issues/3115

相关问题