WebJob работает на моем локальном компьютере. После развертывания в службе приложений WebJob всегда имеет статус «Ожидание перезапуска» со следующими прикрепленными журналами.
[01/13/2020 16:04:03 > 8578d0: SYS INFO] Status changed to Starting
[01/13/2020 16:04:03 > 8578d0: SYS INFO] WebJob singleton setting is False
[01/13/2020 16:04:05 > 8578d0: SYS INFO] Run script 'dotnet-aspnet-codegenerator-design.exe' with script host - 'WindowsScriptHost'
[01/13/2020 16:04:05 > 8578d0: SYS INFO] Status changed to Running
[01/13/2020 16:04:06 > 8578d0: INFO] [Trace]: Command Line:
[01/13/2020 16:04:06 > 8578d0: INFO] [Trace]: at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
[01/13/2020 16:04:06 > 8578d0: INFO] at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
[01/13/2020 16:04:06 > 8578d0: INFO] at Microsoft.VisualStudio.Web.CodeGeneration.Design.Program.<>c__DisplayClass4_0.<<Execute>b__0>d.MoveNext()
[01/13/2020 16:04:06 > 8578d0: ERR ] Scaffolding failed.
[01/13/2020 16:04:06 > 8578d0: ERR ] Value cannot be null.
[01/13/2020 16:04:06 > 8578d0: ERR ] Parameter name: String
[01/13/2020 16:04:07 > 8578d0: SYS INFO] Status changed to Success
[01/13/2020 16:04:07 > 8578d0: SYS INFO] Process went down, waiting for 60 seconds
[01/13/2020 16:04:07 > 8578d0: SYS INFO] Status changed to PendingRestart
Поскольку строительные леса зависят от NuGet, здесь приведены зависимости NuGet, определенные для проекта
<ItemGroup>
<PackageReference Include="EntityFramework" Version="6.2.0" />
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.10" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="System.Spatial" Version="5.8.4" />
<PackageReference Include="Microsoft.Data.Edm" Version="5.8.4" />
<PackageReference Include="Microsoft.Data.OData" Version="5.8.4" />
<PackageReference Include="Microsoft.Data.Services.Client" Version="5.8.4" />
<PackageReference Include="Microsoft.WindowsAzure.ConfigurationManager" Version="3.2.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Core" Version="3.0.14" />
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.14" />
<PackageReference Include="Microsoft.Azure.KeyVault.Core" Version="1.0.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
и определение проекта
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
<GenerateSupportedRuntime>false</GenerateSupportedRuntime>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Platforms>AnyCPU;x64</Platforms>
<RootNamespace>xxx.WebJob</RootNamespace>
</PropertyGroup>
Была такая же проблема с Azure .WebJobs 2.x, обновление до 3.x не дало положительного результата. Основной метод WebJob
public static async Task Main()
{
var hostBuilder = new HostBuilder()
.ConfigureWebJobs(conf => conf.AddAzureStorage())
// custom name resolver to pickup runtime information (dev/test/prod)
.ConfigureServices(services => services.AddSingleton<INameResolver, AppSettingsResolver>())
// set the config file to read azure configurations.
.ConfigureAppConfiguration((context, builder) => builder.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddEnvironmentVariables());
using (var host = hostBuilder.Build())
await host.RunAsync();
}