none
Azure Function: How to use Microsoft.VisualStudio.Services.Client library for calling Azure DevOps RRS feed

  • Question

  • Hello,

    I'm trying to call Azure DevOps from a C# based function (Version 2). To use the above nuget package "Microsoft.VisualStudio.Services.Client" I added a function.prj file as below:

    <Project Sdk="Microsoft.NET.Sdk">  
        <PropertyGroup>  
            <TargetFramework>netstandard2.0</TargetFramework>  
        </PropertyGroup>  
        <ItemGroup>  
            <PackageReference Include="Microsoft.VisualStudio.Services.Client" Version="16.153.0" />  
        </ItemGroup>  
    </Project>

    As soon as I include the "using Microsoft.VisualStudio.Services.Client;" execution ends with a 500 error. Please advise what do I do wrong to get the function running?


    Tuesday, September 10, 2019 3:44 PM

All replies

  • Hello Schnalbi,

    If you need to use "Microsoft.VisualStudio.Services.Client" than the nuget package required is "Microsoft.VisualStudio.Services.InteractiveClient" see this example here

    Once you add Microsoft.VisualStudio.Services.InteractiveClient NugetPackage you will be able to use Microsoft.VisualStudio.Services.Client namespace.

    Hope this helps!

    Thursday, September 12, 2019 4:03 AM
    Moderator
  • Hello MS,

    thanks for trying to help me out. For me this faces a serious problem because the current personal access token I'm using is only suitable for development.

    Unfortunately it is still not working. I included now all three nuget packages which were:

            <PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="16.153.0" />
            <PackageReference Include="Microsoft.VisualStudio.Services.Client" Version="16.153.0" />
            <PackageReference Include="Microsoft.VisualStudio.Services.InteractiveClient" Version="16.153.0" />  

    Below you see the error message from the log:

    2019-09-16T07:56:32.789 [Information] Script for function 'HttpTrigger1' changed. Reloading.

    2019-09-16T07:56:32.903 [Error] run.csx(15,17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
    2019-09-16T07:56:32.940 [Error] run.csx(16,17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
    2019-09-16T07:56:32.979 [Information] Compilation failed.
    2019-09-16T07:56:33.768 [Information] Executing 'Functions.HttpTrigger1' (Reason='This function was programmatically called via the host APIs.', Id=279d998c-3eeb-4011-92a0-e3941beac0de)
    2019-09-16T07:56:33.893 [Error] Function compilation error
    Microsoft.CodeAnalysis.Scripting.CompilationErrorException : Script compilation failed.
       at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.CreateFunctionTarget(CancellationToken cancellationToken) at C:\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 314
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at async Microsoft.Azure.WebJobs.Script.Description.FunctionLoader`1.GetFunctionTargetAsync[T](Int32 attemptCount) at C:\azure-webjobs-sdk-script\src\WebJobs.Script\Description\FunctionLoader.cs : 55
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.GetFunctionTargetAsync(Boolean isInvocation) at C:\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 183
    2019-09-16T07:56:33.939 [Error] run.csx(15,17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
    2019-09-16T07:56:34.084 [Error] run.csx(16,17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
    2019-09-16T07:56:34.118 [Error] Executed 'Functions.HttpTrigger1' (Failed, Id=279d998c-3eeb-4011-92a0-e3941beac0de)
    Script compilation failed.

    Thanks in advance. Best regards Albrecht

    Monday, September 16, 2019 8:08 AM