Azure function not showing up when running solution locally VS 2022

fullstackdeveloper 0 Reputation points
2023-06-22T18:05:51.3+00:00

I've tried many permutations but with so many files and options I think that listing them would be overkill. I'm using Visual Studio 2022 on Windows 10 to create an Azure Functions app (in C# using .Net6 isolated). I am new to Azure Functions but I'm not new to coding. I'm basically creating a repository of Azure functions (each in a separate file) for eventual use. I started with the boilerplate HttpTrigger that simply responds with an acknowledgement on the browser (see fn_httpget.txt). Then I created an HttpTrigger with endpoints to respond with some information (see httpendpoint.txt). Everything so far works.
My issue has to do with the third function where I'm trying to use the same type of HttpTrigger to query an Azure SQL database. See the file httpselect.txt. Assume that the query works. Also, there are no outstanding errors. When I debug/run the project I don't see the "SqlSelect" function like I see the other two.

azureoutput

I've defined the SqlConnectionString inside local.settings.json and it looks as follows:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
    "SqlConnectionString": "Server={xyz,1433};Initial Catalog={dbname};Persist Security Info=False;User ID={username};Password={passwd};"
  }
}

I set a breakpoint in the httpselect.cs file right after the definition of the variable 'connectionString' and the code never seems to reach that point, as if the entire function file is skipped. Note that I've defined the HttpTrigger with a null as well as non-null ("httpselect") Route. I've tried to look for a log file but there doesn't seem to be one (one suggestion was to look a the logs in the Azure "monitor" and so I'm looking for the corresponding thing locally). I realize that the connection to the Azure SQL database could be an issue but I figure that at least there would be an error during the build or when running that particular function/end point. My expectation would be to see three functions in the output, "SqlSelect" being one of them.

If anyone has any suggestions on what could possibly be the problem please send them through. I've tried too many things and I think that a fresh perspective would be helpful. Thank you in advance!

p.s. This is what my host.json looks like.

{
    "version": "2.0",
    "logging": {
        "applicationInsights": {
            "samplingSettings": {
                "isEnabled": true,
                "excludedTypes": "Request"
            }
        }
    }
}

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,529 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,103 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,339 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 29,851 Reputation points Microsoft Employee
    2023-07-19T15:58:50.64+00:00

    Hi @Anonymous

    Sorry for the delayed response. But in your httpselect.cs file, you're using the wrong attribute. That's why the function isn't showing. Change [FunctionName("SqlSelect")] to [Function("SqlSelect")].

    1 person found this answer helpful.

Your answer

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