1

I have an web application (ASP.NET MVC) host on Azure web app service and an console application (C#) as http trigger locally. This Azure web app service will call the .exe once when it's running. They run well this way.
Now I'd like to move the .exe file to Azure and call it from Azure app service. But I only find Azure function app to execute a piece of code written using Azure portal. Is there a possible solution for me to simply upload this exe file to Azure and can be called by Azure app service ?
Thanks in advance.

yzwang
  • 23
  • 1
  • 4

1 Answers1

5

It seems that you would call your console application as http trigger when web app run. If so, you may need to upload your console application as a Azure webjob.

You could right click your console app and choose "Publish as Azure Webjobs" to publish your console app to the Web app on Azure.

enter image description here

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.

For more details about deploy webjobs you could refer to this article.

Also, if you are using console core application, you could refer to this blog to deploy it.

Joey Cai
  • 18,968
  • 1
  • 20
  • 30
  • Glad to see that. You could accept it as answer to close this question. – Joey Cai Aug 20 '18 at 06:02
  • Had one more question. I've created an Azure webjob and upload the .exe file. I noticed that there are three ways to trigger the webjob : Manually, continuously and on schedule. Is there a way to call the webjob by a controller or a piece of code in ASP.NET project ? – yzwang Aug 20 '18 at 06:06
  • According to your description, you could trigger your webjob when you run your web app, so you could choose `continuously` which will always run and when you run webapp, it will trigger at once. – Joey Cai Aug 20 '18 at 06:08
  • You could not call webjob by use webapp to control. They are parallel program. – Joey Cai Aug 20 '18 at 06:10
  • No. As your demand, you want to run webapp to trigger webjob. So, you just set the webjob as `continuously`. Then it will triggered.Azure WebJobs run within the sandbox of the web app. This means that they can access environment variables and share information, such as connection strings, with the web app. The job has access to the unique identifier of the machine that is running the job. – Joey Cai Aug 20 '18 at 06:21
  • But I just want to trigger the webjob in some conditions. I don't want it to run all the time. For example, I used System.Diagnostics.Process.start("Path/name.exe") to launch the exe locally. Now in Azure, should I still use this method ? But what is the path exactly? – yzwang Aug 20 '18 at 07:58
  • You could refer to this [issue](https://stackoverflow.com/questions/28293505/process-start-in-azure-website). Also, you wanna know the path exactly. You could go to KUDU to find where is your webjobs. – Joey Cai Aug 20 '18 at 08:13
  • Thanks Joey! I'll refer to it. – yzwang Aug 20 '18 at 08:35