首页 > 解决方案 > Azure 函数 2.x 中的错误您是否缺少程序集参考?

问题描述

在 c# 中运行 Azure 函数 2.0 时,我在 azure 云门户中遇到错误

The type or namespace name 'Management' does not exist in the namespace 'Microsoft.Azure' (are you missing an assembly reference?)

run.csx 文件是

using System;
using Microsoft.Azure.Management.ContainerInstance.Fluent;

public static void Run(string myEventHubMessage, ILogger log)
{
    log.LogInformation($"C# Event Hub trigger function processed a message: {myEventHubMessage}");
}

它的依赖文件是function.proj

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
    </PropertyGroup>  
    <ItemGroup>
        <PackageReference Include="Microsoft.Azure.Management.ContainerInstance.Fluent" Version="1.16.1" />
    </ItemGroup>
</Project>

标签: c#azureazure-functionsazure-cloud-servicesazure-functions-runtime

解决方案


我尝试使用新的函数应用在门户中重新创建您的问题。起初我遇到了同样的错误,我认为是因为包还原失败或一开始没有运行。尝试删除并重新创建您的 function.proj 文件。


推荐阅读