Skip to content
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
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ To see what is releasing in the FHIR Server, please refer to the [releases](http
- [SMART on FHIR Proxy tutorial](docs/SMARTonFHIR.md): Describes how to use the proxy to enable SMART on FHIR applications with the FHIR Server.
- [FHIR Postman tutorial](https://docs.microsoft.com/azure/healthcare-apis/access-fhir-postman-tutorial): Describes how to access a FHIR API using Postman.
- [Debugging](docs/HowToDebug.md): Describes how to debug FHIR Server for Azure using Visual Studio.
- [Connect to SQL Database](docs/HowToConnectSQLDatabase.md): Describes how to connect to SQL Database.

## Blog Posts
* Blog: [FHIR Server for Azure, an open source project for modern healthcare](https://cloudblogs.microsoft.com/industry-blog/health/2018/11/12/fhir-server-for-azure-an-open-source-project-for-cloud-based-health-solutions/).
Expand Down
43 changes: 43 additions & 0 deletions docs/HowToConnectSQLDatabase.md
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.
Copy link
Member

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?

Copy link
Contributor

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?


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.
Loading