Azure / Azure/azure-rest-api-specs
SQL Data Sync: cannot create Sync Group with version 2015-05-01-preview
- Dominant language
- TypeSpec
- Stars
- 3.1k
- Forks
- 5.9k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 444
Description
**Resource:** https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}
**API Version:** 2015-05-01-preview
Encountering an issue when creating a SQL Data Sync Group via API, that doesn't occur when creating via the Portal. When a Sync Group is created in the Portal, it's possible to PATCH it to add the schema property, but if the Sync Group is created via the published API, the PATCH operation fails.
### Works via Portal
1. Create a SQL Database Server and two databases (a hub DB and a sync DB).
2. Via the "Sync to other databases" pane, create a new sync group and complete the first of 3 wizard pages. This will send the initial PUT request.
3. In pages 2 and 3, enter the DB credentials and select some tables and columns for the sync schema.
4. Note the corresponding PATCH requests to separately add the credentials and the schema.
### To Reproduce
1. Send the observed PUT and 2 x PATCH requests from above to create and update a sync group via API version 2015-05-01-preview (noting the resource schema matches the swagger except for one property, see Other Observations below).
2. After the final PATCH request to add the schema, receive the following error:
```json
{
"error": {
"code": "SyncOperation_GenericFailure",
"message": "Failed to perform data sync operation: '' is invalid schema master"
}
}
```
3. Back in the Portal, complete steps 1 and 2 from above, then attempt to send the 2 x PATCH requests to amend the sync group credentials and schema.
4. Observe no error upon updating the `schema` property.
## Other Observations
When creating a sync group via the portal, it includes an undocumented property `hubDatabaseId` which is set to the resource ID of the hub database. The same database that forms part of the sync group resource ID. Including this property in the PUT request to the API doesn't appear to mitigate the issue.
## Example Requests
```http
PUT /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aaatest-sql/providers/Microsoft.Sql/servers/aaatest/databases/test1/syncGroups/syncQ?api-version=2015-05-01-preview
{
"properties": {
"name": "syncQ",
"interval": -1,
"conflictResolutionPolicy": "HubWin",
"syncDatabaseId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aaatest-sql/providers/Microsoft.Sql/servers/aaatest/databases/sync",
"hubDatabaseId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aaatest-sql/providers/Microsoft.Sql/servers/aaatest/databases/test1"
}
}
```
```http
PATCH /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aaatest-sql/providers/Microsoft.Sql/servers/aaatest/databases/test1/syncGroups/syncQ?api-version=2015-05-01-preview
{
"properties": {
"hubDatabasePassword": "Qwer5678",
"hubDatabaseUsername": "admino"
}
}
```
```http
PATCH /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aaatest-sql/providers/Microsoft.Sql/servers/aaatest/databases/test1/syncGroups/syncQ?api-version=2015-05-01-preview
{
"properties": {
"schema": {
"masterSyncMemberName": "",
"tables": [
{
"columns": [
{
"quotedName": "[ProductID]"
},
{
"quotedName": "[ProductNumber]"
},
{
"quotedName": "[Color]"
}
],
"quotedName": "[SalesLT].[Product]"
}
]
}
}
}
```
Contributor guide
Research direction
Start by replaying the documented PUT and two PATCH requests against API version 2015-05-01-preview and compare them with the Portal requests. Read the sync group resource contract and the example request fields, especially hubDatabaseId and schema. Done means establishing whether the published contract or service behavior causes the final schema PATCH failure and documenting the supported correction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, openapi
- Domain
- api, cloud, databases
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100