Skip to content

Commit 9ee78de

Browse files
author
Cephas Lin
committed
managed identity faq
1 parent 460ef8c commit 9ee78de

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

articles/app-service/tutorial-dotnetcore-sqldb-app.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ The creation wizard generated connection strings for the SQL database and the Re
181181
:::column-end:::
182182
:::row-end:::
183183

184+
> [!TIP]
185+
> The SQL database connection string uses SQL authentication. For more secure, passwordless authentication, see [How do I change the SQL Database connection to use a managed identity instead?](#how-do-i-change-the-sql-database-connection-to-use-a-managed-identity-instead)
186+
184187
## 3. Deploy sample code
185188

186189
In this step, you configure GitHub deployment using GitHub Actions. It's just one of many ways to deploy to App Service, but also a great way to have continuous integration in your deployment process. By default, every `git push` to your GitHub repository kicks off the build and deploy action.
@@ -682,6 +685,29 @@ If a step fails in the autogenerated GitHub workflow file, try modifying the fai
682685
683686
See [Set up GitHub Actions deployment from the Deployment Center](deploy-github-actions.md#set-up-github-actions-deployment-from-the-deployment-center).
684687
688+
### How do I change the SQL Database connection to use a managed identity instead?
689+
690+
The default connection string to the SQL database is managed by Service Connector, with the name *defaultConnector*, and it uses SQL authentication. To replace it with a connection that uses a managed identity, run the following commands in the [cloud shell](https://shell.azure.com):
691+
692+
```azurecli-interactive
693+
az extension add --name serviceconnector-passwordless --upgrade
694+
az sql server update --enable-public-network true
695+
az webapp connection delete sql --connection defaultConnector --resource-group <resource-group> --name <app-name> # replace <app-name>
696+
az webapp connection create sql --connection defaultConnector --resource-group <resource-group> --name <app-name> --target-resource-group msdocs-core-sql-tutorial --server <sql-database-server-name> --database <database-name> --client-type dotnet --system-identity --config-connstr true # replace <app-name>, <sql-database-server-name>, and <database-name>
697+
az sql server update --enable-public-network false
698+
```
699+
700+
By default, they command `az webapp connection create sql --client-type dotnet --system-identity --config-connstr` does the following:
701+
702+
- Sets your user as the Entra ID administrator of the SQL database server.
703+
- Create a system-assigned managed identity and grants it access to the database.
704+
- Generates a passwordless connection string called `AZURE_SQL_CONNECTIONGSTRING`, which your app is already using at the end of the tutorial.
705+
706+
Your app should now have connectivity to the SQL database. For more information, see [Tutorial: Connect to Azure databases from App Service without secrets using a managed identity](tutorial-connect-msi-azure-database.md).
707+
708+
> [!TIP]
709+
> Don't want to enable public network connectivity? You can run it from an [Azure cloud shell that's integrated with your virtual network](../cloud-shell/vnet/deployment.md) if you have the **Owner** role assignment on your subscription.
710+
685711
### What can I do with GitHub Copilot in my codespace?
686712
687713
You might have noticed that the GitHub Copilot chat view was already there for you when you created the codespace. For your convenience, we include the GitHub Copilot chat extension in the container definition (see *.devcontainer/devcontainer.json*). However, you need a [GitHub Copilot account](https://docs.github.com/copilot/using-github-copilot/using-github-copilot-code-suggestions-in-your-editor) (30-day free trial available).

0 commit comments

Comments
 (0)