title: Unable to get Linux container running as Azure function in isolated process
body: <p>The function app runs locally but is deployed as a Linux container. The deployed function isn't reporting any issues in the portal and I can see the three functions listed in the Functions blade. However, none are working (one is a simple HTTP ping which is returning a 502 Bad Gateway response).</p>
  <p>So no obvious issues in the portal, but inspection of logs reveals this recurring exception:</p>
  <blockquote>
  <p>System.Threading.Tasks.TaskCanceledException at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess</p>
  </blockquote>
  <p>The formatted message is:</p>
  <blockquote>
  <p>Failed to start a new language worker for runtime: dotnet-isolated</p>
  </blockquote>
  <p>My suspicion is that this is something to do with the value of the site setting <code>linuxFxVersion</code>. Mind you, I've tried using <code>DOTNET|6.0</code> and <code>DOTNET-ISOLATED|6.0</code>. In both cases it doesn't seem to make a difference and anyway when I export the function app's ARM template it has <code>linuxFxVersion</code> set to the URI of the container image prefixed with <code>DOCKER|</code>.</p>
  <p>That seems to relate to <a href="https://docs.microsoft.com/en-us/azure/azure-functions/set-runtime-version?tabs=azurecli#manual-version-updates-on-linux" rel="nofollow noreferrer">this specific advice from Microsoft</a> about pinning the host version on Linux. But it still isn't clear to me which value I should us, and anyway, in another place the advice from <a href="https://docs.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide#net-isolated-project" rel="nofollow noreferrer">another Microsoft document</a> states:</p>
  <blockquote>
  <p>To support zip deployment and running from the deployment package on Linux, you also need to update the linuxFxVersion site config setting to DOTNET-ISOLATED|6.0.</p>
  </blockquote>
  <p>Anyway, Here are the details of my config. I've followed every bit of guidance from Microsoft so I hope someone can spot what I've missed...</p>
  <p>First two parts of project file:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;net6.0&lt;/TargetFramework&gt;
      &lt;AzureFunctionsVersion&gt;V4&lt;/AzureFunctionsVersion&gt;
      &lt;OutputType&gt;Exe&lt;/OutputType&gt;
      &lt;ImplicitUsings&gt;true&lt;/ImplicitUsings&gt;
      &lt;Nullable&gt;enable&lt;/Nullable&gt;
  &lt;/PropertyGroup&gt;
  &lt;ItemGroup&gt;
      &lt;PackageReference Include=&quot;Microsoft.Azure.Functions.Worker.Extensions.CosmosDB&quot; Version=&quot;3.0.9&quot; /&gt;
      &lt;PackageReference Include=&quot;Microsoft.Azure.Functions.Worker.Extensions.Http&quot; Version=&quot;3.0.13&quot; /&gt;
      &lt;PackageReference Include=&quot;Microsoft.Azure.Functions.Worker.Sdk&quot; Version=&quot;1.3.0&quot; OutputItemType=&quot;Analyzer&quot; /&gt;
      &lt;PackageReference Include=&quot;Microsoft.Azure.Functions.Worker&quot; Version=&quot;1.5.2&quot; /&gt;
  &lt;/ItemGroup&gt;
  </code></pre>
  <p>host.json:</p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;version&quot;: &quot;2.0&quot;,
      &quot;logging&quot;: {
          &quot;applicationInsights&quot;: {
              &quot;samplingSettings&quot;: {
                  &quot;isEnabled&quot;: true,
                  &quot;excludedTypes&quot;: &quot;Request&quot;
              }
          }
      }
  }
  </code></pre>
  <p><code>Main</code> method in Program.cs:</p>
  <pre class="lang-cs prettyprint-override"><code>public static async Task Main()
  {
      var host = new HostBuilder()
          .ConfigureFunctionsWorkerDefaults()
          .ConfigureAppConfiguration((context, configurationBuilder) =&gt;
          {
              configurationBuilder.AddJsonFile(&quot;appsettings.json&quot;, optional: false, reloadOnChange: true);
  
              if (context.HostingEnvironment.IsDevelopment())
              {
                  configurationBuilder.AddJsonFile(&quot;local.settings.json&quot;, optional: true, reloadOnChange: true);
              }
              else
              {
                  configurationBuilder.AddJsonFile($&quot;appsettings.{context.HostingEnvironment.EnvironmentName}.json&quot;, optional: true, reloadOnChange: true);
              }
  
              configurationBuilder.AddEnvironmentVariables();
          })
          .ConfigureServices((context, collection) =&gt; ConfigureServices(collection, context.Configuration, context.HostingEnvironment))
          .Build()
          .RunAsync();
  }
  </code></pre>
  <p>The function provisioning pipeline sets the following app settings:</p>
  <pre><code>FUNCTIONS_EXTENSION_VERSION: '~4'
  FUNCTIONS_WORKER_RUNTIME: 'dotnet-isolated'
  </code></pre>
  <p>As stated above, the latest version of my site config defined during provisioning includes this:</p>
  <pre><code>linuxFxVersion: 'DOTNET-ISOLATED|6.0'
  </code></pre>
  <p>The Docker image uses <code>mcr.microsoft.com/azure-functions/dotnet-isolated:4</code> as a base image for the published app, and <code>mcr.microsoft.com/dotnet/sdk:6.0</code> to build it.</p>
  <p>Please tell me there's something obvious I'm missing. We currently have two function apps, and neither can be deployed as dotnet-isolated. It's driving me mad!</p>