Search code examples
c#.netvisual-studio-2015azure-functionsazure-media-services

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


I'm replicating EncodeBlob_SingleOut_Function from Integrating Azure Media Services with Azure Functions article. It was running on my local when debugging on Visual Studio 2015. However, when I published the function in Azure Portal, I am getting "The type or namespace name 'MediaServices' does not exist in the namespace 'Microsoft.WindowsAzure' (are you missing an assembly reference?)" when compiling. Aside from MediaServices class, the Function app in Azure portal can't find also other objects like CloudMediaContext, MediaServicesCredentials, IAsset, IAccessPolicy, etc.


Solution

  • According to your description, I followed the tutorial you provided and created my Azure Function based on the EncodeBlob_SingleOut_Function sample. After some trials, I could make it work as expected on Azure. Here are some possible causes, you could refer to them:

    Log into Azure Portal, choose your Function App, click "Function app settings > Go to App Service Editor".

    Make sure the content structure of your Azure Funtion looks like this:

    Note: The project.json file is under the root directory of your function. The folder Presets and Shared need to under the root directory of wwwroot. You could find them as follows:

    You could upload directory/file via App Service Editor or KUDU.

    Upon the configuration without change any code, when a blob is uploaded and you could find the function is triggered as follows:

    enter image description here

    enter image description here