-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Steps for connecting to SQL database #4619
Open
v-ajajvanu
wants to merge
2
commits into
main
Choose a base branch
from
personal/v-ajaj/123379
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Connecting to a SQL Database | ||
The procedures for connecting to a SQL database are outlined in this article. | ||
|
||
## Active Directory Administrator for SQL Server | ||
|
||
The user must set themselves as SQL Server Active Directory Admin when they connect to the database for the first time. | ||
|
||
The actions to do are listed below for it. | ||
* Access the SQL Server | ||
* Click on Settings -> Microsoft Entra ID -> Set Admin | ||
![alt text](images/HowToConnectSQLDatabase/entraid-admin.png "Entra Admin") | ||
* Choose the User Account | ||
![alt text](images/HowToConnectSQLDatabase/choose-user-account.png "Entra Admin") | ||
* Press the "Save" button. | ||
![alt text](images/HowToConnectSQLDatabase/save-user-admin-account.png "Entra Admin") | ||
|
||
At this point, the user can connect to the database using `Active Directory authentication`. | ||
|
||
Create a new user in the database and give them the role `db_owner` after connecting to the database. | ||
|
||
The script for the same can be found below: | ||
``` | ||
CREATE USER [user-name] FROM EXTERNAL PROVIDER; | ||
ALTER ROLE db_owner ADD MEMBER [user-name]; | ||
``` | ||
|
||
Example query | ||
``` | ||
CREATE USER [[email protected]] FROM EXTERNAL PROVIDER; | ||
ALTER ROLE db_owner ADD MEMBER [[email protected]]; | ||
``` | ||
|
||
Revert the SQL Server Active directory admin user changes once the user has been created, that is, set the `OSS FHIR Server(App service)` user assigned identity back to SQL Server admin. | ||
|
||
This is a `one-time only` activity. The user can utilize an active directory login to connect directly to the database the next time. | ||
|
||
## Important Information | ||
|
||
|
||
During that time, when the `user-assigned identity` assigned to the `OSS FHIR Server(App service)` is removed as the SQL Server admin, | ||
the App service would degrade since it won't be able to access to the database. | ||
|
||
However, the `OSS FHIR Server(App service)` will return to normal once the user-assigned identity is changed back to admin when the user is created in the database. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SergeyGaluzo is this the recommended approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brendankowitz What problem are we trying to solve? Is something not working with managed identities?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SergeyGaluzo We have worked on creating the documentation on the below mentioned details:
"Currently in OSS, we only have a single login enabled for the SQL Server - the User Assigned Managed Identity that the FHIR Service uses to access the server.
This is a problem because customers may need to access the database directly to check data or they may have other applications that need to access the database. This also could be problematic for FHIR Team devs that need to check the database directly like the JobQueue table.
We need to provide instructions or a script to update the SQL Admin of the user's choosing (maybe the current user??) but also create the SQL Login for the User Assigned Managed Identity.
We cannot do this in pipeline because the identity we you add a SQL user via a service principal, the SQL Server needs a managed identity that has graph read all access."
@brendankowitz FYI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brendankowitz I would suggest different approach. FHIR SQL server does not need FHIR Server UAMI as admin for FHIR server to work, it is just hard to setup by the pipeline. Therefore, I usually "downgrade" UAMI to db owner after FHIR server is setup. This contains similar steps to create login for UAMI and corresponding database user. Setting up user access becomes a separate issue. In certain cases, it could remain admin...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brendankowitz: Please let us know if you suggest us to update the pipeline and documentation with an alternative approach, and if you'd like us to include instructions on providing user access to the database which will be the separate issue as mentioned.