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/service-connector/tutorial-aks-sql.md
+51-51Lines changed: 51 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,113 +29,113 @@ In this tutorial, you learn how to connect an application deployed to AKS, to an
29
29
30
30
## Create an Azure SQL Database
31
31
32
-
1. Create a resource group for this tutorial, where you'll store your Azure resources.
32
+
1. Create a resource group to store the Azure resources you create in this tutorial using the [`az group create`](/cli/azure/group#az_group_create) command.
33
33
34
34
```azurecli-interactive
35
35
az group create \
36
-
--name MyResourceGroup \
36
+
--name $RESOURCE_GROUP \
37
37
--location eastus
38
38
```
39
39
40
-
1. Follow these instructions to [create an Azure SQL Database](/azure/azure-sql/database/single-database-create-quickstart) in the resource group you created. Note your server name, database name, and the database credentials. You will need them later on.
40
+
1. Follow the instructions to [create an Azure SQL Database](/azure/azure-sql/database/single-database-create-quickstart) in the resource group you created in the previous step. Make note of the server name, database name, and the database credentials for use throughout this tutorial.
41
41
42
42
## Create a service connection in AKS with Service Connector (preview)
43
43
44
44
### Register the Service Connector resource provider
45
45
46
-
If you're using Service Connector for the first time, start by running the command [az provider register](/cli/azure/provider#az-provider-register) to register the Service Connector resource provider.
46
+
* If you're using Service Connector for the first time, register the Service Connector resource provider using the [`az provider register`](/cli/azure/provider#az-provider-register) command.
47
47
48
-
```azurecli
49
-
az provider register -n Microsoft.ServiceLinker
50
-
```
48
+
```azurecli-interactive
49
+
az provider register --namespace Microsoft.ServiceLinker
50
+
```
51
51
52
-
> [!TIP]
53
-
> You can check if the resource provider has already been registered by running the command `az provider show -n "Microsoft.ServiceLinker" --query registrationState`. If the output is `Registered`, then Service Connector has already been registered.
52
+
> [!TIP]
53
+
> You can check if the resource provider is already registered using the `az provider show --namespace "Microsoft.ServiceLinker" --query registrationState` command. If the output is `Registered`, then Service Connector is already registered.
54
54
55
55
<!-- check if registering RP is still necessary-->
56
56
57
57
### Create a new connection
58
58
59
59
Create a service connection between your AKS cluster and your SQL database in the Azure portal or the Azure CLI.
60
60
61
-
### [Portal](#tab/azure-portal)
61
+
### [Azure portal](#tab/azure-portal)
62
62
63
-
Open your AKS cluster in the Azure portal, and select **Settings** > **Service Connector (Preview)** in the left menu. Select **Create** and select or enter information following the instructions and examples below. Leave all other settings with their default values.
63
+
1. In the [Azure portal](https://portal.azure.com/), navigate to your AKS cluster resource.
|**Kubernetes namespace**|*default*| The Kubernetes service namespace. |
70
-
|**Service type**|*SQL Database*| Select the target service type you want to connect your. |
71
-
|**Connection name**|*sql_connection*| Use the connection name provided by Service Connector or enter your own connection name. |
72
-
|**Subscription**|*My Subscription*| Select the subscription that includes the Azure SQL Database service. |
73
-
|**SQL server**|*sql_server*| Select your SQL server. |
74
-
|**SQL database**|*sql_db*| Select your SQL database. |
75
-
|**Client type**|*Python*| The code language or framework you use to connect to the target service. |
67
+
* **Kubernetes namespace**: Select **default**.
68
+
* **Service type**: Select **SQL Database**.
69
+
* **Connection name**: Use the connection name provided by Service Connector or enter your own connection name.
70
+
* **Subscription**: Select the subscription that includes the Azure SQL Database service.
71
+
* **SQL server**: Select your SQL server.
72
+
* **SQL database**: Select your SQL database.
73
+
* **Client type**: The code language or framework you use to connect to the target service, such as **Python**.
76
74
77
75
:::image type="content" source="media/tutorial-ask-sql/create-connection.png" alt-text="Screenshot of the Azure portal showing the form to create a new connection to a SQL database in AKS.":::
78
76
79
-
1. In the authentication tab, the connection string authentication method is selected by default, as it's the only method currently supported. Enter your database username and password.
77
+
4. Select **Next: Authentication**. On the **Authentication** tab, enter your database username and password.
6. Once the deployment is successful, you can view information about the new connection in the **Service Connector** pane.
80
80
81
-
1. Select **Next** until you reach the **Review + Create**tab that lists a summary of the configuration entered for the connection. If you're satisfied with the configuration, select **Create**.
81
+
### [Azure CLI](#tab/azure-cli)
82
82
83
-
1. Once the deployment is successful, you can view information about the new connection in the **Service Connector** pane.
84
-
85
-
## [Azure CLI](#tab/azure-cli)
86
-
87
-
1. Get access credentials for your AKS cluster using the [az aks get-credentials](/cli/azure/aks#az-aks-get-credentials) command.
83
+
1. Get access credentials for your AKS cluster using the [`az aks get-credentials`](/cli/azure/aks#az-aks-get-credentials) command.
88
84
89
85
```azurecli-interactive
90
86
az aks get-credentials \
91
-
--resource-group MyResourceGroup \
92
-
--name MyAKSCluster
87
+
--resource-group $RESOURCE_GROUP \
88
+
--name $CLUSTER_NAME
93
89
```
94
90
95
-
1. Use the Azure CLI command [az aks connection create sql](/cli/azure/aks/connection/create#az-aks-connection-create-sql) to create a service connection to the SQL database. There are several ways you can construct this command. For example:
91
+
1. Create a service connection to the SQL database using the [`az aks connection create sql`](/cli/azure/aks/connection/create#az-aks-connection-create-sql) command. You can run this command in two different ways.
96
92
97
-
- run the following interactive command to generate the new connection step by step.
93
+
* Generate the new connection step by step.
98
94
99
-
```azurecli
95
+
```azurecli-interactive
100
96
az aks connection create sql
101
97
```
102
98
103
-
- or run a command following the example below. Replace the placeholders `<source-subscription>`, `<source_resource_group>`, `<cluster>`, `<target-subscription>`, `<target_resource_group>`, `<server>`, `<database>`, and `<***>` with your own information.
99
+
* Generate the new connection at once. Make sure you replace the following placeholders with your own information: `<source-subscription>`, `<source_resource_group>`, `<cluster>`, `<target-subscription>`, `<target_resource_group>`, `<server>`, `<database>`, and `<***>`.
Now that the connection between your AKS cluster and the database is created, retrieve the connection secrets and deploy them in your container.
112
+
Now that you created a connection between your AKS cluster and the database, you need to retrieve the connection secrets and deploy them in your container.
116
113
117
-
1. In the **Service Connector (Preview)** menu, select the newly created connection using the checkbox. Then, select **Yaml snippet**. This action opens a panel displaying a sample YAML file generated by Service Connector.
114
+
1. In the [Azure portal](https://portal.azure.com/) navigate to your AKS cluster resource and select **Service Connector (Preview)**.
115
+
1. Select the newly created connection, and then select **YAML snippet**. This action opens a panel displaying a sample YAML file generated by Service Connector.
118
116
1. To set the connection secrets as environment variables in your container, you have two options:
119
-
- Directly create a deployment using the YAML sample code snippet provided. The snippet includes highlighted sections showing the secret object that will be injected as the environment variables. Select **Apply** to proceed with this method.
117
+
118
+
* Directly create a deployment using the YAML sample code snippet provided. The snippet includes highlighted sections showing the secret object that will be injected as the environment variables. Select **Apply** to proceed with this method.
120
119
121
-
:::image type="content" source="media/tutorial-ask-sql/sample-yaml-snippet.png" alt-text="Screenshot of the Azure portal showing the sample YAML snippet to create a new connection to a SQL database in AKS.":::
120
+
:::image type="content" source="media/tutorial-ask-sql/sample-yaml-snippet.png" alt-text="Screenshot of the Azure portal showing the sample YAML snippet to create a new connection to a SQL database in AKS.":::
122
121
123
-
- Alternatively, under **Resource Type**, select **Kubernetes Workload** and select an existing Kubernetes workload. This action sets the secret object of your new connection as the environment variables for the selected workload. After selecting the workload, select **Apply** to use this method.
122
+
* Alternatively, under **Resource Type**, select **Kubernetes Workload**, and then select an existing Kubernetes workload. This action sets the secret object of your new connection as the environment variables for the selected workload. After selecting the workload, select **Apply**.
124
123
125
-
:::image type="content" source="media/tutorial-ask-sql/kubernetes-snippet.png" alt-text="Screenshot of the Azure portal showing the Kubernetes snippet to create a new connection to a SQL database in AKS.":::
124
+
:::image type="content" source="media/tutorial-ask-sql/kubernetes-snippet.png" alt-text="Screenshot of the Azure portal showing the Kubernetes snippet to create a new connection to a SQL database in AKS.":::
126
125
127
-
### Update your application code
126
+
## Update your application code
128
127
129
-
As a final step, update your application code to use your environment variables, [following these instructions](how-to-integrate-sql-database.md#connection-string).
128
+
* As a final step, update your application code to use your environment variables, by [following these instructions](how-to-integrate-sql-database.md#connection-string).
130
129
131
130
## Clean up resources
132
131
133
-
If you no longer need the resources you created when following this tutorial, remove them by deleting the resource group.
132
+
If you no longer need the resources you created when following this tutorial, you can remove them by deleting the Azure resource group.
133
+
134
+
* Delete your resource group using the [`az group delete`](/cli/azure/group#az_group_delete) command.
0 commit comments