You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/app-service/tutorial-java-jboss-mysql-app.md
+44-4Lines changed: 44 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -692,6 +692,7 @@ You can ignore this Hibernate error because it indicates that the application co
692
692
693
693
- [How much does this setup cost?](#how-much-does-this-setup-cost)
694
694
- [How do I connect to the MySQL server behind the virtual network with other tools?](#how-do-i-connect-to-the-mysql-server-behind-the-virtual-network-with-other-tools)
695
+
- [How do I get a valid access token for the MySQL connection using Microsoft Entra authentication?](#how-do-i-get-a-valid-access-token-for-the-mysql-connection-using-microsoft-entra-authentication)
695
696
- [How does local app development work with GitHub Actions?](#how-does-local-app-development-work-with-github-actions)
696
697
- [I don't have permissions to create a user-assigned identity](#i-dont-have-permissions-to-create-a-user-assigned-identity)
697
698
- [What can I do with GitHub Copilot in my codespace?](#what-can-i-do-with-github-copilot-in-my-codespace)
@@ -702,15 +703,54 @@ Pricing for the created resources is as follows:
702
703
703
704
- The App Service plan is created in**P0v3** tier and can be scaled up or down. See [App Service pricing](https://azure.microsoft.com/pricing/details/app-service/linux/).
704
705
- The MySQL flexible server is created in**D2ds** tier and can be scaled up or down. See [Azure Database for MySQL pricing](https://azure.microsoft.com/pricing/details/mysql/flexible-server/).
705
-
<!-- - The Azure Cache forRedis is createdin**Basic** tier with the minimum cache size. There's a small cost associated with this tier. You can scale it up to higher performance tiers for higher availability, clustering, and other features. See [Azure Cache for Redis pricing](https://azure.microsoft.com/pricing/details/cache/). -->
706
+
- The Azure Cache forRedis is createdin**Basic** tier with the minimum cache size. There's a small cost associated with this tier. You can scale it up to higher performance tiers for higher availability, clustering, and other features. See [Azure Cache for Redis pricing](https://azure.microsoft.com/pricing/details/cache/).
706
707
- The virtual network doesn't incur a charge unless you configure extra functionality, such as peering. See [Azure Virtual Network pricing](https://azure.microsoft.com/pricing/details/virtual-network/).
707
708
- The private DNS zone incurs a small charge. See [Azure DNS pricing](https://azure.microsoft.com/pricing/details/dns/).
708
709
709
710
#### How do I connect to the MySQL server behind the virtual network with other tools?
710
711
711
-
- The JBoss container currently doesn't have the `mysql-client` terminal too. If you want, you must manually install it. Remember that anything you install doesn't persist across app restarts.
712
-
- To connect from a desktop tool like MySQL Workbench, your machine must be within the virtual network. For example, it could be an Azure VM in one of the subnets, or a machine in an on-premises network that has a [site-to-site VPN](../vpn-gateway/vpn-gateway-about-vpngateways.md) connection with the Azure virtual network.
713
-
- You can also [integrate Azure Cloud Shell](../cloud-shell/private-vnet.md) with the virtual network.
712
+
In this tutorial, the App Service app is already has network connectivity to the MySQL server and can authenticate with Microsoft Entra by using its system-assigned managed identity. You can connect to MySQL directly from within the app container by running the following commands in the SSH session (get your `<server>`, `<user>`, and `<database>` values from the `AZURE_MYSQL_CONNECTIONSTRING` app setting):
- The tools you install in the SSH session don't persist across app restarts.
723
+
- If you followed the portal steps and configured MySQL using your Microsoft Entra user as the administrator, you can connect to MySQL using the Microsoft Entra user.
724
+
- To connect from a desktop tool like MySQL Workbench, your machine must be within the virtual network, such as an Azure VM deployed into the same virtual network. You must also configure authentication separately, either with a managed identity or with a Microsoft Entra user.
725
+
- To connect from a machine in an on-premises network that has a [site-to-site VPN](../vpn-gateway/vpn-gateway-about-vpngateways.md) connection with the Azure virtual network, you can't configure authentication with a managed identity, but you can configure authentication by using a Microsoft Entra user.
726
+
- You can also [integrate Azure Cloud Shell](../cloud-shell/private-vnet.md) and connect using Azure CLI or the MySQL CLI. To authenticate, you can configure a Microsoft Entra user.
727
+
728
+
#### How do I get a valid access token for the MySQL connection using Microsoft Entra authentication?
729
+
730
+
For a Microsoft Entra user, a system-assigned managed identity, or a user-asssigned managed identity that's authorizaed to access the MySQL database, Azure CLI can help you generate an access token. In case of a managed identity, the identity must be configured on the App Service app or VM where you run Azure CLI.
731
+
732
+
```azurecli-interactive
733
+
# Sign in as a Microsoft Entra user
734
+
az login
735
+
# Sign in as the system-assigned managed identity
736
+
az login --identity
737
+
# Sign in as a user-assigned managed identity
738
+
az login --identity --username <client-id-of-user-assigned-identity>
739
+
740
+
# Get an access token
741
+
az account get-access-token --resource-type oss-rdbms
742
+
```
743
+
744
+
If you want, you can also use the [az mysql flexible-server connect](/cli/azure/mysql/flexible-server#az-mysql-flexible-server-connect) Azure CLI command to connect to MySQL. When prompted, use the access token as the password.
745
+
746
+
```azurecli-interactive
747
+
az mysql flexible-server connect -n <server-name-only> -u <user> -d <database> --interactive
748
+
```
749
+
750
+
For more information, see:
751
+
- [How to use managed identities for App Service and Azure Functions](overview-managed-identity.md)
752
+
- [Authenticate to Azure using Azure CLI](/cli/azure/authenticate-azure-cli)
753
+
- [Connect to Azure Database for MySQL Flexible Server using Microsoft Entra ID](../mysql/flexible-server/how-to-azure-ad.md#connect-to-azure-database-for-mysql-flexible-server-using-microsoft-entra-id)
714
754
715
755
#### How does local app development work with GitHub Actions?
0 commit comments