CopyPastor

Detecting plagiarism made easy.

Score: 1; Reported for: Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2025-01-20
by Pravallika KV

Original Post

Original - Posted on 2019-04-24
by Shunmugam V



            
Present in both answers; Present only in the new answer; Present only in the old answer;

I can see the [core packages](https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide?tabs=hostbuilder,windows#performance-optimizations) of Isolated Azure functions `Microsoft.Azure.Functions.Worker.Sdk` and `Microsoft.AspNetCore.App` are missing in your `.csproj`, refer [MSDOC](https://learn.microsoft.com/en-us/azure/azure-functions/migrate-dotnet-to-isolated-model?tabs=net8) to upgrade the function from in-process to isolated.
1. Install the NuGet packages `Microsoft.Azure.Functions.Worker.Sdk` with version `1.16.4 or later`.
2. Add the framework reference to `Microsoft.AspNetCore.App`. 3. Add `<Nullable>enable</Nullable>` in `.csproj`.
**.csproj of Service Bus trigger .NET 8.0 Isolated Azure function:** ```xml <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net8.0</TargetFramework> <AzureFunctionsVersion>v4</AzureFunctionsVersion> <OutputType>Exe</OutputType> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> <FrameworkReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" /> <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.0.0" /> <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.22.0" /> <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.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> <ItemGroup> <Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" /> </ItemGroup> </Project> ``` **local.settings.json:** ```json { "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated", "ServiceBusConnection": "ServiceBus_ConnectionString" } } ``` **Code Snippet:**
**Function.cs:** ```csharp [Function(nameof(Function1))] public async Task Run( [ServiceBusTrigger("queue1", Connection = "demo")] ServiceBusReceivedMessage message, ServiceBusMessageActions messageActions) { _logger.LogInformation("Message ID: {id}", message.MessageId); _logger.LogInformation("Message Body: {body}", message.Body); _logger.LogInformation("Message Content-Type: {contentType}", message.ContentType);
await messageActions.CompleteMessageAsync(message); } ```
**Program.cs:**
```csharp using Microsoft.Azure.Functions.Worker; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting;
var host = new HostBuilder() .ConfigureFunctionsWebApplication() .ConfigureServices(services => { services.AddApplicationInsightsTelemetryWorkerService(); services.ConfigureFunctionsApplicationInsights(); }) .Build();
host.Run(); ```
I faced similar issues and finally managed to found the root cause. You may fixed this problem, but putting this here for anyone else facing this problem.
Ensure you have this following block of element in your .csproj in **<ItemGroup></ItemGroup>** of a Function App
``` <None Update="host.json"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> ```
I got this problem when i excluded host.json from the project and then created one again (after realizing this is needed for sure).
valid .csproj should look something like this
``` <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net461</TargetFramework> </PropertyGroup>
... ... ...
<ItemGroup> <None Update="host.json"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> <None Update="local.settings.json"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToPublishDirectory>Never</CopyToPublishDirectory> </None> </ItemGroup> </Project> ```
Hopefully Adding that will solve this issue. Let me know if this helps :)

        
Present in both answers; Present only in the new answer; Present only in the old answer;