2

I have an existing ASP.Net Core 2.0 Web App running on an App Service in Azure. I need to create an Azure Function that gets triggered when new messages get written to an Azure Queue. Is it possible to setup Azure Functions within my existing App Service OR do I need to create an entire new Azure Function based app service? I didn't see any options on the Azure Portal to add Functions to my existing App Service. Obviously, I want to do this to keep Azure resources and costs to a minimum.

Thanks,

PR

juvchan
  • 6,113
  • 2
  • 22
  • 35
Julian.Net
  • 157
  • 1
  • 10

3 Answers3

2

If you would share the App service plan, you could operate as evilSnobu said.

setup Azure Functions within my existing App Service

If you would create an Azure Functions to get trigger, I suggest that you could use WebJobs in your Web App to get triggered when new messages get written to an Azure Queue.

WebJobs is a feature of Azure App Service that enables you to run a program or script in the same context as a web app. There is no additional cost to use WebJobs.

You could use following code to get trigger when a new message written to “logqueue” .

public static void ProcessQueueMessage([QueueTrigger("logqueue")] string logMessage, TextWriter logger)
{
    logger.WriteLine(logMessage);
}

For more details ,you could read this article.

Joey Cai
  • 18,968
  • 1
  • 20
  • 30
  • Thanks for the link. So it looks like WebJobs maybe a better option for me. Could I create WebJobs in the same project/solution as my ASP.Net Core WebApp? Currently I am using the Continuous Integration feature w/ VSTS for build/deploy of my ASP.Net Core WebApp. – Julian.Net Feb 09 '18 at 06:05
  • You could create asp.net core app and publish WebJobs alongside it to azure. You could refer to this [link](https://stackoverflow.com/questions/42857997/publish-simple-asp-net-core-app-net-framework-with-webjob) – Joey Cai Feb 09 '18 at 09:23
  • I am using Visual Studio Code for Mac with the new CI feature pushing from VSTS to Azure WebApp. Could I still publish the WebJob alongside my webapp to Azure? – Julian.Net Feb 13 '18 at 17:19
1

From the point of view of your App Service Plan, your Function App is very similar to a Web App, so indeed you can share the plan. Just pick it from the dropdown.

Create Function App blade

evilSnobu
  • 24,582
  • 8
  • 41
  • 71
  • I do have it setup currently where my App Service Plan is shared between my App Service (ASP.Net Core WebApp) and Function App. It just ended up creating a separate function app with a different URL etc. So I was just trying to simplify to see if I can do it all in 1 app (1 url), less things to maintain/monitor etc. – Julian.Net Feb 09 '18 at 06:03
  • 1
    he asked how to share an app service, not an app service plan – doodlleus Aug 30 '18 at 14:22
  • 1
    What is an "App Service"? – evilSnobu Aug 31 '18 at 06:22
1

If you already have an existing AppServicePlan then you can do it by following 2 steps:

  1. go to the azure portal and create new FuncApp using the UI wizard, in Basic tab just select the resource group and the region where you existing AppServicePlan resides. create new FuncApp(Basic tab). In the Hosting tab select Plan Type = App service plan and select your existing plan. create new FuncApp(Hosting tab)
  2. Go to azure portal -> App Service plans -> select your existing AppServicePlan -> Settings -> Apps -> select your newly created function App -> Functions -> Add

note: using only VS2019 I was unable to create a new function with the existing AppServicePlan, think that VS2019 function wizard has some bugs

Igor
  • 266
  • 1
  • 3
  • 13