Forum Discussion

corsair's avatar
corsair
Copper Contributor
Nov 18, 2024

Publishing blazor web app with an sql db on azure

Hi, 

I have recently attempted to publish my blazor web app on azure however the webpage comes with and error :

HTTP Error 500.30 - ASP.NET Core app failed to start

After checking the web apps Availability and Performance I notice this error:

Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot open server "aidandwaterfordgmail.onmicrosoft.com" requested by the login. The login failed.

 

I have changed the settings on the firewall and the sql connection string does work when hosting off of my local machine. 

Any ideas?

Cheers

 

2 Replies

  • corsair's avatar
    corsair
    Copper Contributor

    Thanks for the time however I have already tried all these things. nothing comes up on log stream and their is no clear reason why this is happening. u deployed from visual studio so maybe their is a setting in their that prevents .net start up. just have no idea to be honest on what to do and am rather annoyed that this has been so complex. The connection string works when website is hosted on my local machine.

    ps i beleve Azure Active Directory (AAD) is now microsoft entra

     

  • Azure Web Apps use App Settings to configure environment variables like connection strings. Ensure your SQL connection string is correctly set there:

    1. Go to the Azure Portal.
    2. Navigate to your App Service > Configuration > Application settings.
    3. Ensure the connection string is added under the Connection Strings section, with the proper name (e.g., DefaultConnection).
    4. Server=tcp:<server-name>.database.windows.net,1433;Initial Catalog=<database-name>;Persist Security Info=False;User ID=<user-id>;Password=<password>;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;

    Ensure the firewall rules for your Azure SQL Database allow connections from:

    1. The Azure Web App service.
      • In the Azure Portal, navigate to your SQL Server.
      • Go to Networking > Firewall and virtual networks.
      • Select Allow Azure services and resources to access this server (toggle to Yes).
    2. Specific IP ranges (if necessary):
      • Add the outbound IP addresses of your Web App under Firewall Rules. You can find the outbound IP addresses in the App Service > Properties section.
      • Verify Authentication Type

        • If your connection string uses an Azure Active Directory (AAD) account (e.g., aidandwaterfordgmail.onmicrosoft.com), ensure the following:
          • The AAD account is added as a database user with the appropriate permissions.
          • Use the Active Directory Interactive authentication type or Active Directory Password in the connection string.
          Example for AAD password authentication:
        • Server=tcp:<server-name>.database.windows.net,1433;Initial Catalog=<database-name>;Persist Security Info=False;User ID=<AAD-user>;Password=<password>;Authentication=Active Directory Password;
        • Check Application Logs for More Details

          • To better understand the issue, enable detailed error logs:
            1. Go to your App Service in Azure.
            2. Navigate to Diagnostics settings > Application Logging and enable it.
            3. Download the logs or check the Log Stream in real time.
          • Look for detailed connection errors in the logs.
          • After making changes, restart your Azure App Service to ensure the updated configuration is applied.

Resources