|
| 1 | +--- |
| 2 | +title: Resource sync |
| 3 | +description: Synchronize resources for Azure Arc-enabled data services in directly connected mode |
| 4 | +services: azure-arc |
| 5 | +ms.service: azure-arc |
| 6 | +ms.subservice: azure-arc-data |
| 7 | +author: dnethi |
| 8 | +ms.author: dinethi |
| 9 | +ms.reviewer: mikeray |
| 10 | +ms.date: 07/14/2022 |
| 11 | +ms.topic: conceptual |
| 12 | +--- |
| 13 | + |
| 14 | +# Resource sync |
| 15 | + |
| 16 | +Resource sync lets you create, update, or delete resources directly on the Kubernetes cluster using Kubernetes APIs in the direct connected mode, and automatically synchronizes those changes to Azure. This article explains resource sync. |
| 17 | + |
| 18 | +[!INCLUDE [azure-arc-data-preview](../../../includes/azure-arc-data-preview.md)] |
| 19 | + |
| 20 | +When you deploy Azure Arc-enabled data services in direct connected mode, the deployment creates a *resource sync* rule. This resource sync rule ensures that the Arc resources such as SQL managed instance created or updated by directly calling the Kubernetes APIs get updated appropriately in the mapped resources in Azure and the resource metadata is continually synced back to Azure. This rule is created within the same resource group as the data controller. |
| 21 | + |
| 22 | + > [!NOTE] |
| 23 | + > The resource sync rule is created by default, during the Azure Arc Data Controller deployment and is only applicable in direct connected mode. |
| 24 | +
|
| 25 | +Without the resource sync rule, the SQL managed instance is created using the following command: |
| 26 | + |
| 27 | +```azurecli |
| 28 | +az sql mi-arc create --name <name> --resource-group <group> --location <Azure location> -–subscription <subscription> --custom-location <custom-location> --storage-class-backups <RWX capable storageclass> |
| 29 | +``` |
| 30 | + |
| 31 | +In this scenario, first the Azure ARM APIs are called and the mapped Azure resource is created. Once this mapped resource is created successfully, then the Kubernetes API is called to create the SQL managed instance on the Kubernetes cluster. |
| 32 | + |
| 33 | +:::image type="content" source="media/resource-sync/resource-sync.png" alt-text="A flowchart demonstrating resource sync from Azure Data Studio or Azure CLI passing information to the Kubernetes API. Then the resource sync operator passes the information to the Azure ARM API."::: |
| 34 | + |
| 35 | +With the resource sync rule, you can use the Kubernetes API to create the Arc-enabled SQL managed instance, as follows: |
| 36 | + |
| 37 | +```azurecli |
| 38 | +az sql mi-arc create --name <name> -k <namespace> --use-k8 --storage-class-backups <RWX capable storageclass> |
| 39 | +``` |
| 40 | + |
| 41 | +In this scenario, the SQL managed instance is directly created in the Kubernetes cluster. The resource sync rule ensures that the equivalent resource in Azure is created as well. |
| 42 | + |
| 43 | +If the resource sync rule is deleted accidentally, you can add it back to restore the sync functionality by using the below REST API. Refer to Azure REST API reference for guidance on executing REST APIs. Please make sure to use data controller Azure resource subscription and resource group. |
| 44 | + |
| 45 | + |
| 46 | +```rest |
| 47 | +https://management.azure.com/subscriptions/{{subscription}}/resourcegroups/{{resource_group}}/providers/microsoft.extendedlocation/customlocations/{{custom_location_name}}/resourcesyncrules/defaultresourcesyncrule?api-version=2021-08-31-preview |
| 48 | +``` |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +```azurecli |
| 53 | + "location": "{{Azure region}}", |
| 54 | + "properties": { |
| 55 | + "targetResourceGroup": "/subscriptions/{{subscription}}/resourcegroups/{{resource_group_of_ data_controller}}", |
| 56 | + "priority": 100, |
| 57 | + "selector": { |
| 58 | + "matchLabels": { |
| 59 | + "management.azure.com/resourceProvider": "Microsoft.AzureArcData" //Mandatory |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +### Limitations: |
| 67 | + |
| 68 | +- Resource sync rule does not hydrate Azure Arc Data controller. The Azure Arc Data controller must be deployed via ARM API. |
| 69 | +- Resource sync only applies to the data services such as Arc enabled SQL managed instance, post deployment of Data controller. |
| 70 | +- Resource sync rule does not hydrate Azure Arc enabled PostgreSQL |
| 71 | +- Resource sync rule does not hydrate Azure Arc Active Directory connector |
| 72 | +- Resource sync rule does not hydrate Azure Arc Instance Failover Groups |
| 73 | + |
| 74 | +## Next steps |
| 75 | + |
| 76 | +[Create Azure Arc-enabled data controller using Kubernetes tools](create-data-controller-using-kubernetes-native-tools.md) |
0 commit comments