Share via

Cant get OAuth2 Azure Function to work

Dirk Sachse 1 Reputation point
2021-10-12T14:17:30.04+00:00

Hi,
I m trying to get this tutorial to work:

https://richardswinbank.net/adf/access_google_analytics_with_azure_data_factory

When I test/run the code, I get the following errors:

2021-10-12T14:11:19  Welcome, you are now connected to log-streaming service. The default timeout is 2 hours. Change the timeout with the App Setting SCM_LOGSTREAM_TIMEOUT (in seconds).
2021-10-12T14:11:19.790 [Error] run.csx(17,14): error CS0246: The type or namespace name 'HttpTrigger' could not be found (are you missing a using directive or an assembly reference?)
2021-10-12T14:11:19.838 [Error] run.csx(17,26): error CS0103: The name 'AuthorizationLevel' does not exist in the current context
2021-10-12T14:11:19.914 [Error] run.csx(17,62): error CS0246: The type or namespace name 'Route' could not be found (are you missing a using directive or an assembly reference?)
2021-10-12T14:11:19.996 [Error] run.csx(19,32): error CS0246: The type or namespace name 'SecretClient' could not be found (are you missing a using directive or an assembly reference?)
2021-10-12T14:11:20.088 [Error] run.csx(19,111): error CS0246: The type or namespace name 'ManagedIdentityCredential' could not be found (are you missing a using directive or an assembly reference?)
2021-10-12T14:11:20.139 [Error] run.csx(22,24): error CS0103: The name 'GoogleCredential' does not exist in the current context
2021-10-12T14:11:20.182 [Warning] warning CS1702: Assuming assembly reference 'Microsoft.AspNetCore.Mvc.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' used by 'Microsoft.AspNetCore.Mvc.Core' matches identity 'Microsoft.AspNetCore.Mvc.Abstractions, Version=3.1.18.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' of 'Microsoft.AspNetCore.Mvc.Abstractions', you may need to supply runtime policy
2021-10-12T14:11:20.209 [Error] Executed 'Functions.GetOAuth' (Failed, Id=45db2f7d-9c62-4a96-b1fa-25a2e921c53f, Duration=968ms)Script compilation failed.

I dont know what I am doing wrong.

Any help is welcome, thanks a lot!

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.


1 answer

Sort by: Most helpful
  1. MughundhanRaveendran-MSFT 12,511 Reputation points
    2021-10-13T04:32:44.507+00:00

    @Dirk Sachse ,

    Thanks for reaching out.

    It appears that you are directly running the code in the Azure http triggered function portal as a csx file. However in the article you are referring to, the function code is written in visual Studio. Since the dlls and assemblies are missing in the portal, you are getting these compile time errors in the log console.

    I would suggest you to use Visual Studio and follow the steps mentioned in the below article to create a http trigger

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs?tabs=in-process

    Once you have created a http triggered function, you can add/ import the necessary dlls/nuget packages and then make sure it is working properly in your local development machine. Once you have confirmed that it is working as expected, you can deploy the function to Azure Functions runtime directly from Visual Studio.

    Deploy function to Azure using Visual Studio : https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs?tabs=in-process#publish-to-azure

    Please note that, once you have deployed/published to Azure , you wont be able to edit the function code in the portal as it becomes read only. It is an easy process to debug and compile the function in Visual Studio and then publish to Azure.

    Feel free to reach out here if you face any issues or have any doubts.

    I hope this helps!

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.