Skip to content

Commit e8edf80

Browse files
author
Jill Grant
authored
Merge pull request #235100 from KarlErickson/doc_04_issue_17595276
edit "Validate the service connector result #234630"
2 parents 1527e9e + 784677b commit e8edf80

File tree

2 files changed

+71
-51
lines changed

2 files changed

+71
-51
lines changed

articles/spring-apps/connect-managed-identity-to-azure-sql.md

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Use Managed identity to connect Azure SQL to Azure Spring Apps app
3-
description: Set up managed identity to connect Azure SQL to an Azure Spring Apps app.
2+
title: Use Managed identity to connect Azure SQL Database to an app deployed to Azure Spring Apps
3+
description: Set up managed identity to connect Azure SQL to an app deployed to Azure Spring Apps.
44
author: karlerickson
55
ms.author: karler
66
ms.service: spring-apps
@@ -9,27 +9,29 @@ ms.date: 09/26/2022
99
ms.custom: devx-track-java, event-tier1-build-2022, passwordless-java, service-connector
1010
---
1111

12-
# Use a managed identity to connect Azure SQL Database to an Azure Spring Apps app
12+
# Use a managed identity to connect Azure SQL Database to an app deployed to Azure Spring Apps
1313

1414
> [!NOTE]
1515
> Azure Spring Apps is the new name for the Azure Spring Cloud service. Although the service has a new name, you'll see the old name in some places for a while as we work to update assets such as screenshots, videos, and diagrams.
1616
1717
**This article applies to:** ✔️ Java ❌ C#
1818

19-
**This article applies to:** ✔️ Basic/Standard tier ✔️ Enterprise tier
19+
**This article applies to:** ✔️ Basic/Standard ✔️ Enterprise
2020

21-
This article shows you how to create a managed identity for an Azure Spring Apps app and use it to access Azure SQL Database.
21+
This article shows you how to create a managed identity for an app deployed to Azure Spring Apps and use it to access Azure SQL Database.
2222

2323
[Azure SQL Database](https://azure.microsoft.com/services/sql-database/) is the intelligent, scalable, relational database service built for the cloud. It’s always up to date, with AI-powered and automated features that optimize performance and durability. Serverless compute and Hyperscale storage options automatically scale resources on demand, so you can focus on building new applications without worrying about storage size or resource management.
2424

2525
## Prerequisites
2626

27-
* Follow the [Spring Data JPA tutorial](/azure/developer/java/spring-framework/configure-spring-data-jpa-with-azure-sql-server) to provision an Azure SQL Database and get it work with a Java app locally
28-
* Follow the [Azure Spring Apps system-assigned managed identity tutorial](./how-to-enable-system-assigned-managed-identity.md) to provision an Azure Spring Apps app with MI enabled
27+
* An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
28+
* [Azure CLI](/cli/azure/install-azure-cli) version 2.45.0 or higher.
29+
* Follow the [Spring Data JPA tutorial](/azure/developer/java/spring-framework/configure-spring-data-jpa-with-azure-sql-server) to provision an Azure SQL Database and get it work with a Java app locally.
30+
* Follow the [Azure Spring Apps system-assigned managed identity tutorial](./how-to-enable-system-assigned-managed-identity.md) to provision an app in Azure Spring Apps with managed identity enabled.
2931

3032
## Connect to Azure SQL Database with a managed identity
3133

32-
You can connect your application deployed to Azure Spring Apps to an Azure SQL Database with a managed identity by following manual steps or using [Service Connector](../service-connector/overview.md).
34+
You can connect your application to an Azure SQL Database with a managed identity by following manual steps or using [Service Connector](../service-connector/overview.md).
3335

3436
### [Manual configuration](#tab/manual)
3537

@@ -38,14 +40,14 @@ You can connect your application deployed to Azure Spring Apps to an Azure SQL D
3840
Connect to your SQL server and run the following SQL query:
3941

4042
```sql
41-
CREATE USER [<MIName>] FROM EXTERNAL PROVIDER;
42-
ALTER ROLE db_datareader ADD MEMBER [<MIName>];
43-
ALTER ROLE db_datawriter ADD MEMBER [<MIName>];
44-
ALTER ROLE db_ddladmin ADD MEMBER [<MIName>];
43+
CREATE USER [<managed-identity-name>] FROM EXTERNAL PROVIDER;
44+
ALTER ROLE db_datareader ADD MEMBER [<managed-identity-name>];
45+
ALTER ROLE db_datawriter ADD MEMBER [<managed-identity-name>];
46+
ALTER ROLE db_ddladmin ADD MEMBER [<managed-identity-name>];
4547
GO
4648
```
4749

48-
The value of the `<MIName>` placeholder follows the rule `<service-instance-name>/apps/<app-name>`; for example: `myspringcloud/apps/sqldemo`. You can also query the MIName with Azure CLI:
50+
The value of the `<managed-identity-name>` placeholder follows the rule `<service-instance-name>/apps/<app-name>`; for example: `myspringcloud/apps/sqldemo`. You can also use the following command to query the managed identity name with Azure CLI:
4951

5052
```azurecli
5153
az ad sp show --id <identity-object-ID> --query displayName
@@ -61,18 +63,15 @@ spring.datasource.url=jdbc:sqlserver://$AZ_DATABASE_NAME.database.windows.net:14
6163

6264
#### [Service Connector](#tab/service-connector)
6365

64-
Configure your app deployed to Azure Spring to connect to an SQL Database with a system-assigned managed identity using the `az spring connection create` command, as shown in the following example.
66+
Configure your app deployed to Azure Spring Apps to connect to an Azure SQL Database with a system-assigned managed identity using the `az spring connection create` command, as shown in the following example.
6567

66-
> [!NOTE]
67-
> These commands require [Azure CLI](/cli/azure/install-azure-cli) version 2.45.0 or higher.
68-
69-
1. Install the Service Connector passwordless extension for the Azure CLI.
68+
1. Use the following command to install the Service Connector passwordless extension for the Azure CLI:
7069

7170
```azurecli
7271
az extension add --name serviceconnector-passwordless --upgrade
7372
```
7473

75-
1. Run the `az spring connection create` command, as shown in the following example.
74+
1. Use the following command to connect to the database:
7675

7776
```azurecli
7877
az spring connection create sql \
@@ -86,11 +85,28 @@ Configure your app deployed to Azure Spring to connect to an SQL Database with a
8685
--system-identity
8786
```
8887

88+
1. Use the following command to check the creation result:
89+
90+
```azurecli
91+
CONNECTION_NAME=$(az spring connection list \
92+
--resource-group $SPRING_APP_RESOURCE_GROUP \
93+
--service $SPRING_APP_SERVICE_NAME \
94+
--app $APP_NAME \
95+
--query '[0].name' \
96+
--output tsv)
97+
98+
az spring connection list-configuration \
99+
--resource-group $SPRING_APP_RESOURCE_GROUP \
100+
--service $SPRING_APP_SERVICE_NAME \
101+
--app $APP_NAME \
102+
--connection $CONNECTION_NAME
103+
```
104+
89105
---
90106

91107
## Build and deploy the app to Azure Spring Apps
92108

93-
Rebuild the app and deploy it to the Azure Spring Apps provisioned in the second bullet point under Prerequisites. Now you have a Spring Boot application, authenticated by a managed identity, that uses JPA to store and retrieve data from an Azure SQL Database in Azure Spring Apps.
109+
Rebuild the app and deploy it to the Azure Spring Apps provisioned in the second bullet point under Prerequisites. You now have a Spring Boot application authenticated by a managed identity that uses JPA to store and retrieve data from an Azure SQL Database in Azure Spring Apps.
94110

95111
## Next steps
96112

articles/spring-apps/how-to-bind-cosmos.md

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ms.custom: devx-track-java, event-tier1-build-2022, ignite-2022, service-connect
1616
1717
**This article applies to:** ✔️ Java ❌ C#
1818

19-
**This article applies to:** ✔️ Basic/Standard tier ✔️ Enterprise tier
19+
**This article applies to:** ✔️ Basic/Standard ✔️ Enterprise
2020

2121
Instead of manually configuring your Spring Boot applications, you can automatically bind select Azure services to your applications by using Azure Spring Apps. This article demonstrates how to bind your application to an Azure Cosmos DB database.
2222

@@ -76,46 +76,50 @@ If you don't have a deployed Azure Spring Apps instance, follow the steps in the
7676

7777
### [Service Connector](#tab/Service-Connector)
7878

79-
1. Use the Azure CLI to configure your Spring app to connect to a Cosmos SQL Database with a system-assigned managed identity by using the `az spring connection create` command, as shown in the following example.
79+
#### Use the Azure CLI
8080

81-
> [!NOTE]
82-
> Updating Azure Cosmos DB database settings can take a few minutes to complete.
83-
84-
```azurecli
85-
az spring connection create cosmos-sql \
86-
--resource-group $AZURE_SPRING_APPS_RESOURCE_GROUP \
87-
--service $AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME \
88-
--app $APP_NAME \
89-
--deployment $DEPLOYMENT_NAME \
90-
--target-resource-group $COSMOSDB_RESOURCE_GROUP \
91-
--account $COSMOSDB_ACCOUNT_NAME \
92-
--database $DATABASE_NAME \
93-
--system-assigned-identity
94-
```
81+
Use the following command to configure your Spring app to connect to a Cosmos SQL Database with a system-assigned managed identity:
9582

96-
> [!NOTE]
97-
> If you're using [Service Connector](../service-connector/overview.md) for the first time, start by running the command `az provider register --namespace Microsoft.ServiceLinker` to register the Service Connector resource provider.
98-
>
99-
> If you're using Cosmos Cassandra, use a `--key_space` instead of `--database`.
83+
> [!NOTE]
84+
> Updating Azure Cosmos DB database settings can take a few minutes to complete.
85+
86+
```azurecli
87+
az spring connection create cosmos-sql \
88+
--resource-group $AZURE_SPRING_APPS_RESOURCE_GROUP \
89+
--service $AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME \
90+
--app $APP_NAME \
91+
--deployment $DEPLOYMENT_NAME \
92+
--target-resource-group $COSMOSDB_RESOURCE_GROUP \
93+
--account $COSMOSDB_ACCOUNT_NAME \
94+
--database $DATABASE_NAME \
95+
--system-assigned-identity
96+
```
97+
98+
> [!NOTE]
99+
> If you're using [Service Connector](../service-connector/overview.md) for the first time, start by running the command `az provider register --namespace Microsoft.ServiceLinker` to register the Service Connector resource provider.
100+
>
101+
> If you're using Cosmos Cassandra, use a `--key_space` instead of `--database`.
102+
103+
> [!TIP]
104+
> Run the command `az spring connection list-support-types --output table` to get a list of supported target services and authentication methods for Azure Spring Apps. If the `az spring` command isn't recognized by the system, check that you have installed the required extension by running `az extension add --name spring`.
100105
101-
> [!TIP]
102-
> Run the command `az spring connection list-support-types --output table` to get a list of supported target services and authentication methods for Azure Spring Apps. If the `az spring` command isn't recognized by the system, check that you have installed the required extension by running `az extension add --name spring`.
106+
#### Use the Azure portal
103107

104-
1. Alternately, you can use the Azure portal to configure this connection by completing the following steps. The Azure portal provides the same capabilities as the Azure CLI and provides an interactive experience.
108+
Alternately, you can use the Azure portal to configure this connection by completing the following steps. The Azure portal provides the same capabilities as the Azure CLI and provides an interactive experience.
105109

106-
1. Select your Azure Spring Apps instance in the Azure portal and select **Apps** from the navigation menu. Choose the app you want to connect and select **Service Connector** on the navigation menu.
110+
1. Select your Azure Spring Apps instance in the Azure portal and select **Apps** from the navigation menu. Choose the app you want to connect and select **Service Connector** on the navigation menu.
107111

108-
1. Select **Create**.
112+
1. Select **Create**.
109113

110-
1. On the **Basics** tab, for service type, select Cosmos DB, then choose a subscription. For API type, select Core (SQL), choose a Cosmos DB account, and a database. For client type, select Java, then select **Next: Authentication**. If you haven't created your database yet, see [Quickstart: Create an Azure Cosmos DB account, database, container, and items from the Azure portal](../cosmos-db/nosql/quickstart-portal.md).
114+
1. On the **Basics** tab, for service type, select Cosmos DB, then choose a subscription. For API type, select Core (SQL), choose a Cosmos DB account, and a database. For client type, select Java, then select **Next: Authentication**. If you haven't created your database yet, see [Quickstart: Create an Azure Cosmos DB account, database, container, and items from the Azure portal](../cosmos-db/nosql/quickstart-portal.md).
111115

112-
1. On the **Authentication** tab, choose **Connection string**. Service Connector automatically retrieves the access key from your Cosmos DB account. Select **Next: Networking**.
116+
1. On the **Authentication** tab, choose **Connection string**. Service Connector automatically retrieves the access key from your Cosmos DB account. Select **Next: Networking**.
113117

114-
1. On the **Networking** tab, select **Configure firewall rules to enable access to target service**, then select **Next: Review + Create**.
118+
1. On the **Networking** tab, select **Configure firewall rules to enable access to target service**, then select **Next: Review + Create**.
115119

116-
1. On the **Review + Create** tab, wait for the validation to pass and then select **Create**. The creation can take a few minutes to complete.
120+
1. On the **Review + Create** tab, wait for the validation to pass and then select **Create**. The creation can take a few minutes to complete.
117121

118-
1. Once the connection between your Spring apps and your Cosmos DB database has been generated, you can see it in the Service Connector page and select the unfold button to view the configured connection variables.
122+
1. Once the connection between your Spring apps and your Cosmos DB database has been generated, you can see it in the Service Connector page and select the unfold button to view the configured connection variables.
119123

120124
### [Service Binding](#tab/Service-Binding)
121125

@@ -152,7 +156,7 @@ Azure Cosmos DB has five different API types that support binding. The following
152156

153157
### [Terraform](#tab/Terraform)
154158

155-
The following Terraform script shows how to set up an Azure Spring Apps app with an Azure Cosmos DB account.
159+
The following Terraform script shows how to set up an app deployed to Azure Spring Apps with an Azure Cosmos DB account.
156160

157161
```terraform
158162
provider "azurerm" {

0 commit comments

Comments
 (0)