There is no such restriction in providing a certain class name for Azure function. It accepts all the class names including **Workflows** and **WorkflowTemplates** too.
- For testing purpose, I have below code in ***`Workflows.cs`*** class.
```csharp
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;
using System.Net;
namespace _78470050
{
public class Workflows
{
private readonly ILogger<Workflows> _logger;
public Workflows(ILogger<Workflows> logger)
{
_logger = logger;
}
[Function("GetWorkflows")]
[ProducesResponseType(typeof(IEnumerable<Workflow>), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(string), (int)HttpStatusCode.BadRequest)]
[ProducesResponseType((int)HttpStatusCode.Unauthorized)]
public async Task<IActionResult> RunGetWorkflows([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "Workflows")] HttpRequest req)
{
return await Middleware.Run(async () => await GetWorkflows(req), req, _logger);
}
public static async Task<IActionResult> GetWorkflows(HttpRequest req)
{
var workflows = new List<Workflow>
{
new Workflow { Id = 1, Name = "Workflow 1" },
new Workflow { Id = 2, Name = "Workflow 2" },
};
return new OkObjectResult(workflows);
}
}
public class Workflow
{
public int Id { get; set; }
public string Name { get; set; }
}
}
```
**.csproj**-
```csharp
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>_78470050</RootNamespace>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.2.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.3-preview1" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
```
I am able to get the expected response.
![enter image description here](https://i.imgur.com/yb76KYL.png)
```csharp
Azure Functions Core Tools
Core Tools Version: 4.0.5700 Commit hash: N/A +71cc84964a60bfb07d95839b7c666bd239507bdd (64-bit)
Function Runtime Version: 4.33.2.22572
[2024-05-13T08:22:02.827Z] Found C:\Users\******\78470050\78470050\78470050.csproj. Using for user secrets file configuration.
[2024-05-13T08:22:05.843Z] Azure Functions .NET Worker (PID: 24468) initialized in debug mode. Waiting for debugger to attach...
[2024-05-13T08:22:05.885Z] Worker process started and initialized.
Functions:
GetWorkflows: [GET] http://localhost:7280/api/Workflows
For detailed output, run func with --verbose flag.
[2024-05-13T08:22:10.970Z] Host lock lease acquired by instance ID '000000000000000000000000BF6D1ED5'.
[2024-05-13T08:22:20.536Z] Executing 'Functions.GetWorkflows' (Reason='This function was programmatically called via the host APIs.', Id=564778a5-b570-4ae1-8208-4ebfcb9dd053)
[2024-05-13T08:22:20.851Z] Middleware: Pre-processing logic executed.
[2024-05-13T08:22:20.851Z] Middleware: Post-processing logic executed.
[2024-05-13T08:22:20.858Z] Executing OkObjectResult, writing value of type 'System.Collections.Generic.List`1[[_78470050.Workflow, 78470050, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'.
[2024-05-13T08:22:20.952Z] Executed 'Functions.GetWorkflows' (Succeeded, Id=564778a5-b570-4ae1-8208-4ebfcb9dd053, Duration=479ms)
```
A .Net 8 Isolated Function with Http Trigger and Timer Trigger should have the below packages in its `.csproj` file.
**.csproj**-
```csharp
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>_77832689</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.20.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.4" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
```
The package `Microsoft.AspNetCore.App` which you are referring in your .csproj file is been deprecated. But without using this package also your function should work alike me.
![enter image description here](https://i.imgur.com/hVjDz12.png)
I also having a Timer Trigger and Http Trigger function. Here I am not using Startup class, as to execute the mentioned functions, `Program.cs` file is sufficient.
**TimerTriggerFunction.cs**-
```csharp
using System;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;
namespace Company.Function
{
public class TimerTrigger1
{
private readonly ILogger _logger;
public TimerTrigger1(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger<TimerTrigger1>();
}
[Function("TimerTriggeredFunction")]
public void Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer)
{
_logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
if (myTimer.ScheduleStatus is not null)
{
_logger.LogInformation($"Next timer schedule at: {myTimer.ScheduleStatus.Next}");
}
}
}
}
```
**HttpTriggerFunction.cs**-
```csharp
using System.Net;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;
namespace _77832689
{
public class HttpTriggeredFunction
{
private readonly ILogger _logger;
public HttpTriggeredFunction(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger<HttpTriggeredFunction>();
}
[Function("HttpTriggeredFunction")]
public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req)
{
_logger.LogInformation("C# HTTP trigger function processed a request.");
var response = req.CreateResponse(HttpStatusCode.OK);
response.Headers.Add("Content-Type", "text/plain; charset=utf-8");
response.WriteString("Welcome to Azure Functions!");
return response;
}
}
}
```
**Program.cs**-
```csharp
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(services => {
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
})
.Build();
host.Run();
```
**local.settings.json**-
```json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
}
}
```
Having all these configurations in place, I am able to get the expected response.
![enter image description here](https://i.imgur.com/02cB23I.png)