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" />
Related
I am building a .Net Core 3.1 WebAPI and I would be deploying it on the Azure Web Service. I want to enable the App Insight
At present, I have the following nuget packages
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.20.0" />
<PackageReference Include="Microsoft.ApplicationInsights.Agent.Intercept" Version="2.4.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.20.0" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.20.0" />
<PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.20.0" />
<PackageReference Include="Microsoft.ApplicationInsights.TraceListener" Version="2.20.0" />
<PackageReference Include="Microsoft.ApplicationInsights.Web" Version="2.20.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer" Version="2.20.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" Version="2.20.0" />
<PackageReference Include="Microsoft.AspNet.TelemetryCorrelation" Version="1.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.20.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="1.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>
However, I think, I just need the following packages
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.20.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="1.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.20.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.20.0" />
<PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.20.0" />
</ItemGroup>
How do I know what are all the packages are required to support Azure App Insight and what is not required?
Thank you #VenkateshDodda-MSFT for the comment
As per this Document,
For collecting logs with Application Insights in .NET Applications , we need to add the below Nuget Package
Microsoft.ApplicationInsights.AspNetCore
After adding the Microsoft.ApplicationInsights.AspNetCore package , the below packages are added by default
Microsoft.ApplicationInsights.WorkerService nuget package is required to enable Application Insights for background services
Please refer What is created when you add Application Insights for more information
Last summer I switched to using blob storage and KeyVault to store and encrypt my data protection keys for my simple .NET Core web app. I did this so users would not have to log back in after I swapped my deployment environment from staging to production.
I used the following page as a guide. https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/overview?view=aspnetcore-5.0
Here is my startup config.
services.AddDataProtection()
.PersistKeysToAzureBlobStorage(new Uri($"{dpSettings.BlobUrl}{dpSettings.SasToken}"))
.ProtectKeysWithAzureKeyVault(new Uri(dpSettings.KeyVaultUrl), new DefaultAzureCredential());
References Used
<PackageReference Include="Azure.Extensions.AspNetCore.DataProtection.Keys" Version="1.0.2" />
<PackageReference Include="Azure.Identity" Version="1.3.0" />
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
<PackageReference Include="EPPlus" Version="4.5.3.2" />
<PackageReference Include="HtmlSanitizer" Version="5.0.376" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.17.0" />
<PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.17.0" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.AzureStorage" Version="3.1.13" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="5.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" PrivateAssets="All" />
<PackageReference Include="Postmark" Version="4.5.0" />
<PackageReference Include="Stripe.net" Version="35.17.0" />
<PackageReference Include="TimeZoneConverter" Version="3.4.0" />
It works great but... after 90 days, the site stops working and the following error is reported.
Message: An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information.
Stacktrace:
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Protect(Byte[] plaintext)
at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgeryTokenSerializer.Serialize(AntiforgeryToken token)
at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.Serialize(IAntiforgeryFeature antiforgeryFeature)
at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.GetAndStoreTokens(HttpContext httpContext)
at...
After some troubleshooting I found that the keys.xml file in the blob storage had an expiration date of today. My understanding is that a new key should be created as the expiration date approaches. To fix, I just delete the keys.xml file, and then the app creates a new one. I suppose I could automate this, but I'm pretty sure I shouldn't have to. Any help is appreciated.
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>
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>