How to deploy .NET Core console app as WebJob?

Elizabeth McKinnie 20 Reputation points
2023-01-26T04:08:47.2833333+00:00

I have a .NET Core console app I want to deploy as a webjob. Unfortunately I'm on a Mac and it seems that publishing from Visual Studio for webjobs is only for Windows.

I've tried to upload a .zip file containing the published project, including with a run.cmd file which contains "dotnet project.dll", through the resource itself, but I keep getting "Failed to add project" with no other explanation.

What am I missing here? Is there some issue with using a Mac to generate the zip file, or to do the publish action? (My web app is hosted by Windows machines). Also for what it's worth, there isn't a web app running on this, I created this just for testing. And when I go to "Console" under development tools and just type "ls" it says it failed to execute the command.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,830 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ryan Hill 25,476 Reputation points Microsoft Employee
    2023-01-26T19:47:00.1933333+00:00

    Hi @Elizabeth McKinnie , set the <OutputType /> in your csproj to Exe, build, and upload that exe as the webjob.

    <Project Sdk="Microsoft.NET.Sdk;Microsoft.NET.Sdk.Publish">
      <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net6.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
      </PropertyGroup>
      <ItemGroup>
        <PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="4.0.1" />
        <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.0.1" />
        <PackageReference Include="Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.33" />
        <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
      </ItemGroup>
      ...
    </Project>
    

    The platform will detect the executable and automatically run it based on the trigger configuration.


    EDIT 2023 Feb 13

    Updating for the broader community. Based on our offline conversation, you received a window that said the WebJob failed to create. We inspected that response for that action and noticed it was 403 error. When we attempted to access the Kudu site, that was blocked. We checked the network settings and notice access restrictions were applied for both the main site and the advanced tool site (i.e. Kudu). This was the root the cause of the issue and removed the restriction on your Kudu site.

    You were able to proceed with uploading your published zip file but the platform couldn't determine the file to run since your zip contained two different executables. To work around this issue, you were going to create a .cmd file that the platform can use to start the WebJob.


0 additional answers

Sort by: Most helpful