命名空间 'Microsoft.WindowsAzure' 中不存在类型或命名空间名称 'MediaServices'(是否缺少程序集引用?)

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

我正在从 Integrating Azure Media Services with Azure Functions 文章中复制 EncodeBlob_SingleOut_Function。在 Visual Studio 2015 调试时,它在我的本地是 运行。但是,当我在 Azure 门户中发布函数时,我在编译时得到 "The type or namespace name 'MediaServices' does not exist in the namespace 'Microsoft.WindowsAzure' (are you missing an assembly reference?)"。除了 MediaServices class,Azure 门户中的 Function 应用程序也找不到其他对象,例如 CloudMediaContext、MediaServicesCredentials、IAsset、IAccessPolicy 等

根据您的描述,我按照您提供的 tutorial 并根据 EncodeBlob_SingleOut_Function 示例创建了我的 Azure 函数。经过一些试验,我可以让它在 Azure 上按预期工作。以下是一些可能的原因,您可以参考:

登录Azure Portal,选择你的Function App,点击"Function app settings > Go to App Service Editor"。

确保您的 Azure Funtion 的内容结构如下所示:

注意: project.json 文件位于函数的根目录下。文件夹PresetsShared需要在wwwroot的根目录下。您可以通过以下方式找到它们:

您可以通过应用服务编辑器或 KUDU 上传directory/file。

在不修改任何代码的情况下,当一个blob被上传时,你会发现函数被触发如下:

布鲁斯反应很好, 是的,这与 nugget 和包管理器有关。下拉 Project.json 文件中的 nugget 包似乎存在问题。 我之前已经注意到这一点,但还没有弄清楚是什么触发了这个问题。

我今天会对此进行更多调查,看看我是否能找到 nugget 偶尔失败的原因。

另请注意,我最近刚刚更新了软件包版本,因为有更新的版本可用。

{
  "frameworks": {
    "net46": {
      "dependencies": {
        "windowsazure.mediaservices": "3.8.0.3",
        "windowsazure.mediaservices.extensions": "3.8.0.3"
      }
    }
  }
}