Azure / azure-functions-vs-build-sdk

MSBuild task for Azure Functions
MIT License
96 stars 62 forks source link

Cannot find value in local.settings.json in in-process Azure Function #622

Closed michasacuer closed 5 months ago

michasacuer commented 6 months ago

I get back to my function after couple of months and it stopped working. When i try to run Azure Function locally i receive errors like:

Warning: Cannot find value named 'CosmosDbConection' in local.settings.json that matches 'connection' property set on 'cosmosDB' in 'CosmosFunction\function.json'. You can run 'func azure functionapp fetch-app-settings ' or specify a connection string in local.settings.json.

But local settings json is presented and copied to output directory. My .csproj looks like this:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <AzureFunctionsVersion>V4</AzureFunctionsVersion>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Azure.Identity" Version="1.10.4" />
        <PackageReference Include="Azure.Storage.Blobs" Version="12.19.1" />
        <PackageReference Include="Dapper" Version="2.1.24" />
        <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues" Version="5.2.0" />
        <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="4.4.2" />
        <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.13.5" />
        <PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0-preview3.23201.1" />
        <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
    </ItemGroup>
    <ItemGroup>
        <None Update="host.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
        <None Update="local.settings.json">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
            <CopyToPublishDirectory>Never</CopyToPublishDirectory>
        </None>
        <None Update="appsettings.json">
          <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </None>
    </ItemGroup>
</Project>

Any ideas what i can check to make sure that my function reads local.settings.json properly?

bhagyshricompany commented 5 months ago

Thanks for connecting pls share the all repro steps

microsoft-github-policy-service[bot] commented 5 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.