【问题标题】:Unable to run time triggered function with CosmosDB Binding in Azure as SpringBoot App无法在 Azure 中使用 CosmosDB Binding 作为 SpringBoot App 运行时间触发函数
【发布时间】:2019-08-26 14:22:52
【问题描述】:

无法打包虚拟应用程序

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource to D:\MyFiles\akarforma\Downloads\hello-spring-function-azure-master\target\azure-functions\spring-mongtotimer
[INFO] Copied successfully.
[INFO] Step 7 of 7: Installing function extensions if needed
Extensions command requires dotnet on your path. Please make sure to install dotnet (.NET Core SDK) for your system from https://www.microsoft.com/net/download
[ERROR]
[ERROR] Failed to install the Function extensions
[INFO] ---------------------------------------------------

并且在将其发布到 Azure 后得到

错误:

Function (spring-mongtotimer/hellodummy) Error: The binding type(s) 'cosmosDB' are not registered. Please ensure the type is correct and the binding extension is installed.





   @FunctionName("helloTimer") 
public void execute(@TimerTrigger(name = "timerInfo", schedule = "*/1 * * * * *") String timerInfo,@CosmosDBInput(name = "documents", databaseName = "db1", collectionName = "col1", connectionStringSetting = "dbStr") Optional<String>documents,ExecutionContext context){

【问题讨论】:

    标签: azure spring-boot azure-functions azure-cosmosdb azure-cosmosdb-mongoapi


    【解决方案1】:

    似乎要生成包,您需要dotnet CLI。你得到的错误是因为你生成的包不包含扩展(Cosmos DB 是一个扩展):

    Extensions command requires dotnet on your path. Please make sure to install dotnet (.NET Core SDK) for your system from https://www.microsoft.com/net/download
    [ERROR]
    [ERROR] Failed to install the Function extensions
    

    您是否使用最新的 Azure Functions CLI?

    【讨论】:

    • 你说的有道理....我试过这个 npm i -g azure-functions-core-tools@core --unsafe-perm true 并开始创建一个包.... .thr 一定是版本有问题。
    • 但是当我尝试在本地系统上运行它时,我仍然得到“未注册绑定类型'cosmosDB'。请确保类型正确并安装了绑定扩展。”
    • 该错误意味着未加载引用“cosmosDB”的扩展。它下面实际上是一个 C# 扩展,但我对 Java 不够熟悉,无法知道为什么它没有加载。
    猜你喜欢
    • 1970-01-01
    • 2019-11-01
    • 1970-01-01
    • 2022-08-18
    • 2018-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多