question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`func new` breaking for .NET Isolated

See original GitHub issue

On multiple recent versions (tested on Windows and WSL), the basic project setup for .NET Isolated will fail.

func init --worker-runtime "dotnet-isolated" --target-framework "net7.0"
func new --name "DotNet7Function" --template "HTTP trigger"

will yield

Restore failed.
Post action failed.

The function "DotNet7Fucntion" was created successfully from the "HTTP trigger" template.

with the first two lines as error statements.

The appropriate .NET SDKs and runtimes are available in the test environments. A dotnet restore works just fine.

Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
shiggancommented, May 19, 2023

I am seeing a slightly different issue; as suggested I ignore the ‘restore failed, post action failed’ and go ahead to build the project and it explodes; seems to be specific to --worker-runtime dotNetIsolated as --worker-runtime dotNet works

┌[shiggan@home]
└[D:\CODE\broke]> dotnet --version
7.0.302
┌[shiggan@home]
└[D:\CODE\broke]> func --version
4.0.5148

Broken

┌[shiggan@home]
└[D:\CODE\broke]> func init --worker-runtime dotNetIsolated


Writing D:\CODE\broke\.vscode\extensions.json
┌[shiggan@home]
└[D:\CODE\broke]> func new --name Welcome -t HttpTrigger -a anonymous
Use the up/down arrow keys to select a template:Function name: Welcome
Restore failed.
Post action failed.


The function "Welcome" was created successfully from the "HttpTrigger" template.
┌[shiggan@home]
└[D:\CODE\broke]> dotnet build
MSBuild version 17.6.1+8ffc3fe3d for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
  bug -> D:\CODE\broke\bin\Debug\net7.0\bug.dll
  Determining projects to restore...
C:\Users\shiggan\AppData\Local\Temp\iqd3dhbg.hdt\WorkerExtensions.csproj : warning NU1603: Microsoft.Azure.Functions.Worker.Extensions depends on Microsoft.NET.Sdk.Functions (>= 4.1.3) but Microsoft.NET.Sdk.Functions 4.1.3 was not
found. An approximate best match of Microsoft.NET.Sdk.Functions 4.2.0 was resolved.
C:\Users\shiggan\AppData\Local\Temp\iqd3dhbg.hdt\WorkerExtensions.csproj : error NU1102: Unable to find package Microsoft.NETCore.Targets with version (>= 3.0.0)
C:\Users\shiggan\AppData\Local\Temp\iqd3dhbg.hdt\WorkerExtensions.csproj : error NU1102:   - Found 3 version(s) in Microsoft Visual Studio Offline Packages [ Nearest version: 1.1.0 ]
  Failed to restore C:\Users\shiggan\AppData\Local\Temp\iqd3dhbg.hdt\WorkerExtensions.csproj (in 530 ms).

Build FAILED.

C:\Users\shiggan\AppData\Local\Temp\iqd3dhbg.hdt\WorkerExtensions.csproj : warning NU1603: Microsoft.Azure.Functions.Worker.Extensions depends on Microsoft.NET.Sdk.Functions (>= 4.1.3) but Microsoft.NET.Sdk.Functions 4.1.3 was not
found. An approximate best match of Microsoft.NET.Sdk.Functions 4.2.0 was resolved.
C:\Users\shiggan\AppData\Local\Temp\iqd3dhbg.hdt\WorkerExtensions.csproj : error NU1102: Unable to find package Microsoft.NETCore.Targets with version (>= 3.0.0)
C:\Users\shiggan\AppData\Local\Temp\iqd3dhbg.hdt\WorkerExtensions.csproj : error NU1102:   - Found 3 version(s) in Microsoft Visual Studio Offline Packages [ Nearest version: 1.1.0 ]
    1 Warning(s)
    1 Error(s)

Time Elapsed 00:00:03.95
┌[shiggan@home]
└[D:\CODE\broke]>

Working

┌[shiggan@home]
└[D:\CODE\works]> func init --worker-runtime dotNet


Writing D:\CODE\works\.vscode\extensions.json
┌[shiggan@home]
└[D:\CODE\works]> func new --name Welcome -t HttpTrigger -a anonymous
Use the up/down arrow keys to select a template:Function name: Welcome


The function "Welcome" was created successfully from the "HttpTrigger" template.
┌[shiggan@home]
└[D:\CODE\works]> dotnet build
MSBuild version 17.6.1+8ffc3fe3d for .NET
  Determining projects to restore...
D:\CODE\works\works.csproj : warning NU1603: works depends on Microsoft.NET.Sdk.Functions (>= 4.1.1) but Microsoft.NET.Sdk.Functions 4.1.1 was not found. An approximate best match of Microsoft.NET.Sdk.Functions 4.2.0 was resolved.
  Restored D:\CODE\works\works.csproj (in 497 ms).
D:\CODE\works\works.csproj : warning NU1603: works depends on Microsoft.NET.Sdk.Functions (>= 4.1.1) but Microsoft.NET.Sdk.Functions 4.1.1 was not found. An approximate best match of Microsoft.NET.Sdk.Functions 4.2.0 was resolved.
  works -> D:\CODE\works\bin\Debug\net6.0\works.dll

Build succeeded.

D:\CODE\works\works.csproj : warning NU1603: works depends on Microsoft.NET.Sdk.Functions (>= 4.1.1) but Microsoft.NET.Sdk.Functions 4.1.1 was not found. An approximate best match of Microsoft.NET.Sdk.Functions 4.2.0 was resolved.
D:\CODE\works\works.csproj : warning NU1603: works depends on Microsoft.NET.Sdk.Functions (>= 4.1.1) but Microsoft.NET.Sdk.Functions 4.1.1 was not found. An approximate best match of Microsoft.NET.Sdk.Functions 4.2.0 was resolved.
    2 Warning(s)
    0 Error(s)

Time Elapsed 00:00:05.93
┌[shiggan@home]
└[D:\CODE\works]>
0reactions
c0g1t8commented, Mar 25, 2023

@fabiocav @soninaren

I’ve just verifed the issue is in the template.

# install the template package from Nuget
dotnet new install Microsoft.Azure.Functions.Worker.ItemTemplates::4.0.2288
# create new isolated function
dotnet new http --name WeatherForecastFunction1 --namespace apitest --language "c#" --AccessRights anonymous
PS C:\git\bug-free-sniffle\apitest> # install the template package from Nuget
PS C:\git\bug-free-sniffle\apitest> dotnet new install Microsoft.Azure.Functions.Worker.ItemTemplates::4.0.2288
The following template packages will be installed:
   Microsoft.Azure.Functions.Worker.ItemTemplates::4.0.2288

Success: Microsoft.Azure.Functions.Worker.ItemTemplates::4.0.2288 installed the following templates:
Template Name           Short Name       Language  Tags
----------------------  ---------------  --------  ----------------------------------------
BlobTrigger             blob             [C#],F#   Azure Function/Trigger/Blob
CosmosDBTrigger         cosmos,CosmosDB  [C#],F#   Azure Function/Trigger/Cosmos DB        
EventGridTrigger        eventgrid        [C#],F#   Azure Function/Trigger/EventGrid        
EventHubTrigger         eventhub         [C#],F#   Azure Function/Trigger/EventHub
HttpTrigger             http             [C#],F#   Azure Function/Trigger/Http
QueueTrigger            queue            [C#],F#   Azure Function/Trigger/Storage Queue    
RabbitMQTrigger         rqueue           [C#]      Azure Function/Trigger/RabbitMQ Queue   
ServiceBusQueueTrigger  squeue           [C#]      Azure Function/Trigger/Service Bus/Queue
ServiceBusTopicTrigger  stopic           [C#]      Azure Function/Trigger/Service Bus/Topic
SignalRTrigger          signalr          [C#]      Azure Function/Trigger/Http/SignalR     
TimerTrigger            timer            [C#],F#   Azure Function/Trigger/Timer

PS C:\git\bug-free-sniffle\apitest> # create new isolated function
PS C:\git\bug-free-sniffle\apitest> dotnet new http --name WeatherForecastFunction1 --namespace apitest --language "c#" --AccessRights anonymous
'.
info : Restoring packages for C:\git\bug-free-sniffle\apitest\apitest.csproj...
info : Package 'Microsoft.Azure.Functions.Worker.Extensions.Http' is compatible with all the specified frameworks in project 'C:\git\bug-free-sniffle\apitest\apitest.csproj'.info : PackageReference for package 'Microsoft.Azure.Functions.Worker.Extensions.Http' version '3.0.13' updated in file 'C:\git\bug-free-sniffle\apitest\apitest.csproj'.
info : Assets file has not changed. Skipping assets file writing. Path: C:\git\bug-free-sniffle\apitest\obj\project.assets.json
log  : Restored C:\git\bug-free-sniffle\apitest\apitest.csproj (in 309 ms).
Successfully added a reference to the project file.

Restoring C:\git\bug-free-sniffle\apitest\WeatherForecastFunction1.cs:
C:\git\bug-free-sniffle\apitest\WeatherForecastFunction1.cs(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. 
 Line 1, position 1.
Restore failed.
Post action failed.


An update for template package 'Microsoft.Azure.Functions.Worker.ItemTemplates::4.0.2288' is available.
To update the package use:
   dotnet new install Microsoft.Azure.Functions.Worker.ItemTemplates::4.0.2408
Read more comments on GitHub >

github_iconTop Results From Across the Web

Guide for running C# Azure Functions in an isolated worker ...
Learn how to use a .NET isolated worker process to run your C# functions in Azure, which supports non-LTS versions of .NET and...
Read more >
Containerised Azure function (v4, dotnet-isolated) breaks ...
I'm trying to build an Azure function to run as a Linux container image in an isolated process using .NET 6 and v4...
Read more >
Create an Azure Function .NET in the isolated worker model
This article will review how to create your first Azure Function .Net isolated. Introduction. The .NET Worker provides .NET 5 support in Azure...
Read more >
Migrating to Isolated Durable Functions
NET 7 to use Durable Functions in an isolated model function app. ... for Azure Functions, my recommendation would be to create any...
Read more >
Microsoft Details Sneak-Peek Preview of Azure Functions ...
NET 5.0 isolated process Azure Functions apps. Now, with the ground-breaking and unifying .NET 6 LTS release coming up in November, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found