Deploying to Azure

I'm back...

So I have my app working locally using Azure Active Directory authentication and all is well. I can deploy to Azure with no errors (App Service with a SignalR service configured as well).

When I hit my app with any browser, I am directed to the authentication page, and on successful authentication I am sent back to the main page of my app. On this page I have a text box and a button with a hidden grid. When you enter something into the text box and click the button, EF executes a stored procedure which returns rows. When deployed to Azure entering text and clicking the button has no effect at all.

If I refresh the page, everything disappears (text box, button, banner, image - literally everything). I have just a white page. You cannot refresh to get anything, even if you close the browser. In order to get anything again, you have to sign out of the account, go back through the authentication process and then you get everything - which still does not work.

I have added the database configuration string to the App Service, so it should work. I am concerned by the refresh problem, though - that tells me something else is wrong. I have the configuration information in appsettings for the SignalR service. Nothing seems to work when deployed.

Just to be clear, I am deploying a Release configuration, as well as using that locally. The database I connect to in Azure I am also using locally, so it is not the database. If I add the service configuration for SignalR in Startup, I get the same behavior locally as in Azure - and nothing changes in Azure, so it doesn't appear to be configuration-related.

As I said, locally this is fine and works as expected. Any ideas why it behaves so differently in Azure?

Hi @dferreira042,

Unfortunately we are not sure what the problem could be. Are there any JS errors in the browser console? Any exceptions logged in the Azure portal?

If I add the service configuration for SignalR in Startup, I get the same behavior locally as in Azure - and nothing changes in Azure, so it doesn't appear to be configuration-related.

Do you mean that enabling Azure SignalR locally breaks the application?

Yes, enabling Azure SignalR locally causes the same problem - worse, I can't debug to see where the problem is. It is obviously out of process and the debugger can't attach to it, so all my breakpoints get the extremely helpful message that the breakpoint will never be hit.

No errors logged in the console, nothing in App Insights. Just nothing anywhere.

Unfortunately we aren't that experienced with Azure SignalR.

  1. Does the whole application not work when you enable it or just some particular functionality? If the latter - what is the actual code?
  2. Does a simple Blazor application created with dotnet new blazorserver work as expected if you configure it with Azure SignalR?

At the moment I am shooting at the dark but I don't have anything better to suggest.

I appreciate the help. I didn't have SignalR enabled at all - when I deployed it the first time, Visual Studio told me I was using SignalR and needed to set up the service. That's when I saw the SignalR NuGet package and found out Blazor server side code uses it.

I am going to try a few things this morning and see if there is some magical combination. I'll post back here if I learn anything, positive or negative.

On a separate subject, the latest Radzen build breaks discovery of custom methods. I added a method to the MainLayout partial class, then went into Radzen. I added some stuff to the Load event for the Main layout, and then at the end tried to add an Invoke Method line. The scan for new methods did not work and the method that already existed in the partial class was not present in the list (no methods were there, but then I only had the one). I can't get that method recognized (it is a simple function with no input and returns void) no matter how hard I try, so I had to add the designer to the ignored code list and manually call the method in the Load event.

I can't get that method recognized (it is a simple function with no input and returns void) no matter how hard I try, so I had to add the designer to the ignored code list and manually call the method in the Load event.

Can you share the implementation of the method? We would like to try and reproduce this issue. You can also send the complete code to info@radzen.com.

Nevermind. I think I reproduced it. Will release a fix with the next Radzen release.

I haven’t tried Blazor on Azure not Az SignalR service but a couple ideas: did you confirm web sockets is turned on in your app service? Also perhaps try deploying to Vanilla App Service without using Azure SignalR Service to rule out a level of complexity.
See: http://blazorhelpwebsite.com/Blog/tabid/61/EntryId/4349/Deploying-A-Server-Side-Blazor-Application-To-Azure.aspx
HTH,Josh

Thanks, Josh...web sockets are on.

I think I found my problem - I am injecting the IHttpContextAccessor into some methods to obtain the user's email address and that is my problem. Locally it works just fine, deployed to IIS it works just fine, but when running in Azure it does not. No error logged anywhere, just a blank white screen because processing has stopped (and it happens in a place from which I can't trap the error). Once I remove the injection, everything functions as it should. Sort of, anyway - the very first time the app is started, the one and only button on the main form does nothing when clicked. Reloading the page (and getting a new connection as a result) resolves the problem until the next time the app is shut down.

You better not depend on IHttpContextAccessor in Blazor applications. We've had a lot of issues with it and try to not use it at all. It is initialized either too early or too late or its HttpContext property is disposed or points to an old request. Ideally you should use AuthenticationStateProvider which seems to work well.