Raymond Raymond

Resolve - Azure Function App Publish Specific Target Not Existing in VS2019

event 2021-08-21 visibility 386 comment 0 insights toc
more_vert
insights Stats

Problem statement

When following official tutorial Develop and publish .NET 5 functions using Azure Functions, the Specific target for Azure Function App doesn't exist in the wizard.

Environment: Visual Studio 2019 16.11.1 (the latest version).

Azure Tools: Included when installing Visual Studio.

.NET version: 5.0 (isolated).

Resolution

To fix this problem, simply add the following highlighted package reference (Microsoft.Azure.Functions.Workder.Sdk)  in your project file:

<Project Sdk="Microsoft.NET.Sdk">
	<PropertyGroup>
		<TargetFramework>net5.0</TargetFramework>
		<AzureFunctionsVersion>v3</AzureFunctionsVersion>
		<OutputType>Exe</OutputType>
	</PropertyGroup>
	<ItemGroup>
		<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.5.1" />
		<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.0.4" />
		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="4.0.4" />
		<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="5.0.0" />
        </ItemGroup>
	<ItemGroup>
		<None Update="host.json">
			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
		</None>
		<None Update="local.settings.json">
			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
			<CopyToPublishDirectory>Never</CopyToPublishDirectory>
		</None>
	</ItemGroup>
</Project>
Rebuild after changing project file and then start Publish wizard. Azure Function App should then show up as the following screenshot shows:
2021082184343-image.png

Blob triggered function

For Blob triggered function template with .NET 5 in Visual Studio 2019, you will encounter compiler errors like could not find FunctionAttribute or BlobTriggerAttribtue class. The resolution is already provided in the above sample project file - add the right package references:

<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.5.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.0.4" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="4.0.4" />

Refer to .NET isolated process guide for .NET 5.0 in Azure Functions | Microsoft Docs for details.

warning At the moment, the Visual Studio 2019 support for .NET Azure Functions are not very user friendly thus it is important to add the package references accordingly.
More from Kontext
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts