Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
325 stars 56 forks source link

Static Web App deploy fails with no error details when using C# Azure Function as API with "FunctionsStartup" configuration #244

Open nazar-kuzo opened 3 years ago

nazar-kuzo commented 3 years ago

image

Having deploy of the same version without Startup file (for dependency injection) it deploys with no error

plamber commented 3 years ago

Hello, we are experiencing the same issue. Support for dependency injection is key for some projects.

br,

anthonychu commented 3 years ago

@plamber Is it possible to share your code or a sample that reproduces the problem?

/cc @annaji-msft

plamber commented 3 years ago

Hi @anton-kokorev, you can reproduce it by following the standard provisioning process.

Afterwards, you just need to rename the Github workflow yml file name to something else. Starting from that point, the link is no more up-to-date in Azure.

You can still execute the workflows though.

br, Patrick

nazar-kuzo commented 3 years ago

@plamber, were you intentionally mentioning @anton-kokorev, or it was a question to me?

plamber commented 3 years ago

Hi @nazar-kuzo, sorry. Just recognized that I answered the wrong thread. I thought I answer a question of another issue I opened.

@anton-kokorev: unfortunately, I can't share my repository but you should be able to reproduce the error with this project template. We inject the Microsoft Identity Web library and some other internal libraries in the Startup.

br, Patrick

davidobrien1985 commented 1 year ago

@anthonychu @annaji-msft this is still an issue. I just stumbled upon the same error when adding dependency injection to our static web app. This is following the exact same process like in any other Azure Function. On SWA this fails though. Major blocker now.

Here's our Startup.cs:

using System;
using app;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;

[assembly: FunctionsStartup(typeof(Startup))]
namespace app
{
    public class Startup : FunctionsStartup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme =  JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(options =>
            {
                options.Authority = Environment.GetEnvironmentVariable("auth0Authority");
                options.Audience = System.Environment.GetEnvironmentVariable("auth0Audience");
            });
        }

        public override void Configure(IFunctionsHostBuilder builder)
        {
            ConfigureServices(builder.Services);
        }
    }
}
nazar-kuzo commented 1 year ago

@davidobrien1985 run away from this approach to more complex but predictable deployment of UI and API separately, since 2+ years of no resolution for this bug should tell you something 😉

davidobrien1985 commented 1 year ago

Yeah, decided to run the Functions ourselves now, and will likely also move the frontend to a different service, probably just a Storage Account. Pity.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Nazar Kuzo @.> Sent: Wednesday, January 11, 2023 11:12:40 PM To: Azure/static-web-apps @.> Cc: David O'Brien @.>; Mention @.> Subject: Re: [Azure/static-web-apps] Static Web App deploy fails with no error details when using C# Azure Function as API with "FunctionsStartup" configuration (#244)

@davidobrien1985https://github.com/davidobrien1985 run away from this approach to more complex but predictable separate deployment of UI and API separately, since 2 years of no resolution for this bug should tell you something 😉

— Reply to this email directly, view it on GitHubhttps://github.com/Azure/static-web-apps/issues/244#issuecomment-1378658500, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACBIQGJE57YGVVTTPTHXBJLWR2PTRANCNFSM4VGEL2RA. You are receiving this because you were mentioned.Message ID: @.***>