We currently have deployed a V1 Azure Function and are looking to upgrade this to V2[preview]. However I can't see any way to target .NET Framework 4.6.1 at the moment, only .NET Core when creating a v2 function.
Is it possible use .NET Framework in Azure Function v2?
The Function Runtime in v2 only runs on .NET Core 2.0, so there is no way to target .NET Framework 4.6.1.
Using Visual Studio 2017 Preview 2, I was able to create a 4.61 Azure Functions Library.
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
My full csproj
PLEASE NOTE (future readers) this is subject to change as time goes by and the "preview" becomes integrated into the "real" VS2017.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs" Version="2.1.0-beta1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="2.1.0-beta1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="1.0.0-beta1" />
<PackageReference Include="Microsoft.Azure.WebJobs.ServiceBus" Version="2.1.0-beta1" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.0-alpha3" />
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.2" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
<PackageReference Include="Unity" Version="4.0.1" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Related
I'm running FunctionApp v4(Azure) and ServiceBusTrigger binding and blob binding, but its not fired, messages are not read from subscription. The app is running ok.
Im running functionapps v3 without any problems, the code is copied and packagereferences is updated. When I run locally, everything works fine.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
<!-- if this is not set, Microsoft optimizes away necessary assemblies for dependency injection and authentication-->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.8.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.0.1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
I have to update a project in which i have to update project from netcore 3.1 to net6
it was using
Microsoft.Azure.Cosmos.Table
i have updated it to
Azure.Data.Tables
as per Microsoft suggestion
i have updated all other reference but now i am facing issue that
TableClientConfiguration
don't exist it .net 6
my project file is
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Data.Tables" Version="12.6.1" />
<PackageReference Include="Azure.Storage.Queues" Version="12.12.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Core" Version="3.0.33" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="4.0.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Moq" Version="4.18.2" />
</ItemGroup>
</Project>
even this microsoft for this class dont have help of this
https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.cosmos.table.tableclientconfiguration?view=azure-dotnet
any idea with what i need to update it
or do i need to change the implementation ?
The migration guide shows a sample where it is simply removed.
The main settings there were related to how the connection to CosmosDB was done (Preferred region, Consistency Level, ...).
_tableClient = storageAccount.CreateCloudTableClient(
new TableClientConfiguration {
CosmosExecutorConfiguration = new CosmosExecutorConfiguration {
CurrentRegion = config.ApplicationRegion } });
This is not available in the new SDK (yet):
https://github.com/Azure/azure-sdk-for-net/issues/28986
https://github.com/Azure/azure-sdk-for-net/issues/30943
I would like to run Azure Function v1 with .Net461/.Net472 for testing NotificationHub package. However, there is exception when executing below code:
await _hub.CreateOrUpdateRegistrationAsync(registration);
Error is :
Exception while executing function: PushRegister. Microsoft.Azure.NotificationHubs: Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=XXX' or one of its dependencies. The system cannot find the file specified.
I tried to downgrade to 10.0.3 then had error like
Microsoft.Azure.NotificationHubs: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0 ...
Below is the XXX.csproj file for reference:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<AzureFunctionsVersion>v1</AzureFunctionsVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.3" />
<PackageReference Include="Microsoft.Azure.NotificationHubs" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.ServiceBus" Version="2.3.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\YYY\YYY.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Configuration" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Most of the Nuget libraries have the dependency on Newtonsoft package, even the Microsoft.NET.Sdk.Functions has a dependency on it but it is of older version.
You cannot use any other Nuget Packages that have a dependency on Newtonsoft.Json version which is higher than the function runtime dependent version.
When you try to install a NuGet which has the dependency on a higher version of Newtsonsoft package, you simply cannot install it. The only solution is to use an older version of that library that you need.
I have also written a blog on this and on github this is already an open issue
https://medium.com/#hharan618/common-issues-while-development-of-azure-functions-76b08299af58
I have netcoreapp1.1 that I am trying to publish to Azure with WebDeploy. I am able to do dotnet publish and deploy the contents to Azure, but the site just says "You do not have permission to view this directory or page.", which suggests the app is not running.
My previous apps have used net461 as target framework and I have noticed that publishing these (with dotnet publish) have caused a web.config file to be created, which explains how IIS is able to run it, but this does not happen when the target framework is netcoreapp1.1.
The command I have been using to publish is this:
dotnet publish --configuration Release --runtime win7-x64 --output .deploy
Here is my project file:
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
</PropertyGroup>
<ItemGroup>
<Compile Include="Controllers/*.fs" />
<Compile Include="Startup.fs" />
<Compile Include="Program.fs" />
<None Remove="**/*.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FSharp.Core" Version="4.1.*" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
</ItemGroup>
</Project>
How am I meant to run a netcoreapp1.1 on Azure? Does it have to be self contained or is it possible to have the Azure App Service run it from dlls?
Edit:
Manually copying a web.config into my publish directory I am able to get the app to run. How can I make dotnet publish create it automatically?
Also, I am still curious about my previous questions.
Add info into you csproj file that you need to copy web.config, like this:
<ItemGroup>
<Content Update="web.config">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
I have migrated my project.json to csproj using the 'Dotnet migrate' command from the terminal. But now I can no longer build or publish my app for osx or Linux using a command like 'dotnet build -f osx.10.11-x64' when I run this it iutputs the following. I also don't think the csproj created by the migrate tool will create a self contained app which is what I had before by removing the 'type=platform' from the project.json.
C:\Program Files\dotnet\sdk\1.0.0-rc4-004771\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(84,5): error : Cannot infer TargetFrameworkIdentifier and/or TargetFrameworkVersion from TargetFramework='osx.10.11-x64'. They must be specified explicitly.
This is my csproj file that was created by the migrate command.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>sample</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Kosmele</PackageId>
<RuntimeIdentifiers>osx.10.11-x64;ubuntu.16.04-x64</RuntimeIdentifiers>
<RuntimeFrameworkVersion>1.0.3</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<Content Update="wwwroot\**\*;web.config">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.1" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.1" />
</ItemGroup>
</Project>
The following bare bones .csproj file (for a ASP.NET MVC project) worked for me on OS X.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.0.1" />
</ItemGroup>
</Project>