Reputation: 41
I'd like to deploy an ASP.net Core project to Google AppEngine (flex). My application uses Microsoft Identity/Authentication and has 2 different types of roles. When setting up the project, I chose authentication with individual user accounts and to "store user accounts in-app" - so the information is stored on a local SQL server. I have 2 questions:
1) Is it possible to have the user accounts stored on remote SQL server - specifically Google Cloud SQL? If so, what file(s) do I edit, and what is the proper syntax? I've tried adjusting the connection string in appsettings.json, but it did not work (it stated there was an issue connecting to the SQL server).
2) If the app is deployed as is, what will happen to the locally stored user accounts and roles? Will they transfer to the deployed project on Google Cloud AppEngine?
I'm very new to this and appreciate any help I can get! Thanks!
Upvotes: 0
Views: 649
Reputation: 41
To answer my first question:
Yes you can. The connection string goes in appsettings.json, e.g.:
"ConnectionStrings": {"AuthenticationString": "Server=tcp:SERVERNAME,PORTNUMBER;Initial Catalog=authentication;Persist Security Info=False;User ID=USERNAME;Password=PASSWORD;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"}
and you reference the name of it in startup.cs in the ConfigureServices method, e.g.:
options.UseSqlServer(Configuration.GetConnectionString("AuthenticationString")));
The reason I kept getting errors was because I was trying to store it in a remote MySQL server (I was unaware that Google Cloud SQL was MySQL/Postgre SQL and also hopelessly unaware there was a difference between MySQL and (MS)SQL Server). The method in the startup I referenced UseSqlServer
was clearly meant for a (MS)SQL Server but I have an inkling that there's a similar method if you had wanted to use a MySQL server instead.
(And the second question was answered by Ggrimaldo above)
Upvotes: 1
Reputation: 327
For the first question, I think there are some details to take into account.
Cloud SQL was thought to have its own in-built authentication system, therefore I think the integration of these two systems offers you the possibility to authenticate in two different layers, within the cloud, and within your application.
Therefore, I think it's important that you correctly configure both authentication flows in order to have a functional system.
Even though it may not be the exact resource for the application you are using, it may be worth looking at the guide in .NET to Authenticate users within App Engine. And how to connect App engine flex with MySQL. These two steps are crucial for your External and internal App engine authentication.
For your second question, unfortunately the process is not that automatic. As I wrote above, the credentials will be only for the "internal layer" of your app, if you want to migrate all of them to the external layer (the GCP project) deploying won't be enough, you will have to manually add them, or if your organisation is too large, you will have to use an automated way to do it. (i.e with the API)
Upvotes: 0