How to run azure function locally with HTTPS from visual studio 2022

Paul Franklin 0 Reputation points
2023-10-26T09:29:33.5833333+00:00

I am trying to run azure functions locally with HTTPS from visual studio 2022 but haven't managed to get it working.

No messages on startup related to HTTPS so I don't know if it is trying but failing or simply not even trying HTTPS.

New win 11 build & install of VS 2022 as of a few days ago - I can test fine against HTTP locally and run against HTTPS when deployed to Azure.

Have tried using local.settings.json with a couple of variations of settings that have been suggested from searches ..

Have tried putting suggested 'host' commands in the debug command line section ..

Have created a self signed cert that is in the local machine store and referenced that.

Have created a .pfx file in solution directory and referenced that.

Project properties are:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Data.SqlClient" Version="3.0.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
    <None Update="launchSettings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,483 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Mike Urnun 9,776 Reputation points Microsoft Employee
    2023-10-27T05:05:30.7266667+00:00

    Hello @Paul Franklin - Thanks for reaching out. Running Functions locally under HTTPS requires additional configuration. You'll need to create a certificate locally and configure Visual Studio to use it when starting the host process. Could you try out the steps in the following blog post and see if it helps?


    Please "Accept Answer" if the answer is helpful so that others in the community may benefit from your experience.

    0 comments No comments