Forum Discussion
Azure SQL mirroring to Fabric fails with Error occured while interacting with landing zone
- 10 months ago
Update to this,
I found a reddit post with the same issue,
https://www.reddit.com/r/MicrosoftFabric/comments/1o696yw/the_issue_of_creating_mirrored_databases_using/
Its pointed out that the SAMI needs permission on the mirrored database item.Also when reading the fine prints in the documentation its stated there as well.
So its really down to me not grasping the details.
Once I added the SAMI to the mirroring object, API works fine for setting up the mirroring.
Thanks spaceman127 for your time
hi spaceman127 ,
Tested adding your config, but the result is same as before.
I have a large number of databases, so GUI approach is no option.
Any other suggestions?
Hi lobitconsulting ,
all right.
I will test it and then let you know if I can reproduce the error. I have also already read up on the API.
If everything goes well, I will get to it in the next few days.
Could you perhaps share your complete code here?
Best regards
- lobitconsulting10 months agoFrequent Visitor
Hi spaceman127
Thanks for your time,
I removed some debug code to make it more compact, but in essence this is my pyspark notebook.
I did not include the connection object, this was created in GUI and I refer to the same connection object both in my GUI test and API test.
When doing the calls I authenticate as myself. The connection object is using service principal towards the database.import requests, json, base64, uuid token = mssparkutils.credentials.getToken("pbi") workspaceId = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" connectionId = "xxxxxxxxxxxxxxxxxxxxxxxxx" DATABASE = "mirrortesting" # ====== HEADERS ====== headers = { "Authorization": f"Bearer {token}", "Content-Type": "application/json" } # ====== Create Mirroring Variables ====== urlCreateMirror = "https://api.fabric.microsoft.com/v1/workspaces/" + workspaceId + "/mirroredDatabases" payloadUnencoded = { "properties": { "source": { "type": "AzureSqlDatabase", "typeProperties": { "connection": connectionId, "database": DATABASE } }, "target": { "type": "MountedRelationalDatabase", "typeProperties": { "defaultSchema": "dbo", "format": "Delta", "landingZone": { "type": "Managed" } } } } } b64 = base64.b64encode(json.dumps(payloadUnencoded).encode('utf-8')).decode('utf-8') display_name = f"Mirror Instance {DATABASE}" body = { "displayName": display_name, "description": "Mirror created in notebook", "definition": { "parts": [ { "path": "mirroring.json", "payload": b64, "payloadType": "InlineBase64" } ] } } # ====== Create Mirroring API CALL ===== resp = requests.post(urlCreateMirror, headers=headers, data=json.dumps(body), timeout=120) mirroredDbId = resp.json()["id"] time.sleep(20) #wait for Initialized # ====== Start Mirroring ====== urlStart = "https://api.fabric.microsoft.com/v1/workspaces/" + workspaceId + "/mirroredDatabases/" + mirroredDbId + "/startMirroring" resp = requests.post(urlStart, headers=headers, data=json.dumps({}), timeout=120) time.sleep(20) #wait for 'Running' # ====== Check status ====== urlStatus = "https://api.fabric.microsoft.com/v1/workspaces/" + workspaceId + "/mirroredDatabases/" + mirroredDbId + "/getMirroringStatus" respStatus = requests.post(urlStatus, headers=headers, data=json.dumps({}), timeout=120) print(json.dumps(respStatus.json(), indent=2))