0

I've just published my first Blazor WASM app (ASP.NET Core hosted) to Azure app service and I set it up to use Azure SQL just to get started. I'd like to change the connection now and instead point my app to an SQL Server database on a cloud server we rent, but I'm struggling to figure out how to do it.

I've logged into Azure, gone to configuration, removed the default connection string and added my alternative connection string and saved, but my app still seems to be pointed at the Azure SQL database.

When I ran my code from Visual Studio, the connection string was stored in my appsettings.json but this seems to have become redundant in my published app.

I'm also not sure if the format of my connection string is right. This worked when I was building the app on my machine so I kind of assumed it would be okay in production too:

Server=xxx.xxx.xxx.xxx;Database=DatabaseName;User ID=UserId;Password=Password;MultipleActiveResultSets=true;Application Name=EntityFramework

1 Answer 1

0

Blazor Web Assembly (WASM) runs on your local client. It will not have access to the Azure App Settings part. You would need a Server component for this. If you use Blazor Server or ASP.NET MVC for it, it would be fine.

In general, I'd advise you to introduce an API middle layer between the database and a client-side App as having the connection string in the WASM client has some risks, as every user can easily extract it using the browsers developer tools.

Sign up to request clarification or add additional context in comments.

2 Comments

Sorry, I should have added in my question that my Blazor WASM is ASP.NET Core hosted. I have a server component and it was the appsettings.json file in this project where I was storing the connection string.
I think Blazor Server works a bit different than a simple ASP.NET App devblogs.microsoft.com/dotnet/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.