Powershell and Azure SQL Database Sync - azure

We are using the SQL Database Sync feature in Azure and whilst it generally works without issues it does occasionally fail. The failures can be due to lost database connections or failures in which the error messages in the Azure Sync Log don't help. I see no way in the Azure portal to set up alerts to email us when a sync fails and I don't see any Azure cmdlets that will return the status of a database sync. Does anyone have any ideas how we can add monitoring to the service?
Thanks!

I did crosspost this later to the msdn forum that user6133663 listed below.
The answer from Xu Ye (who I assume works for MS) was:
You are right. Currently SQL Data Sync did not support API & failure alert. We will keep you update if any update on this.
So, to answer my original question, there is currently no way to monitor the success or failure of a SQL database sync.

Related

What does "Can not connect to the database in its current state" mean on azure-sql?

I have recently started receiving "Can not connect to the database in its current state." when trying to connect to my Azure SQL database. As far as I am aware nothing has changed and I get the same error using the query tool in the Azure portal itself using etiher sql authentication or Azure Ad authentication.
The server status is "online" and the trouble-shooter says that it can not find any issues. I have a limit on the billing of the account but have not hit it.
I cant find any way of "restarting" the sql instance or any logs that indicate what might be wrong. I cant raise a support ticket as the troubleshooter suggests that nothing is wrong.
Does anyone have any insight as to what might cause this or what I might try to get it resovled?
Edit: I believe that this is an error code for a Billing issue now - despite the billing appearing fine the subscription is disabled. All of the help articles indicated that code changes were needed to connect reliably but I dont think that is the case.
thanks in advance.
Are you using Key Vault with Azure SQL Database? Make sure permissions to the key vault are properly set.
Another possible reason is the database may be in recovery state. In that case you may have to create a support ticket here.

Azure Sql DB Restore not showing up in Azure portal but stuck restoring in SSMS

I have had an Azure SQL DB point in time restore running for two days. I want to cancel it as I think there is an issue. I can see the DB restoring in SSMS but can't find the deployment in my Azure Portal. Does anyone know how to cancel it? I have tried using Azure CLI but I can't see the resource.
It's called Azure Hiccups, it happened to me yesterday on Switzerland West region between 10:20 and 10:40.
I re-run it and everything was fixed.
If I check the Activity Log I can see the error:
But if I browse in the Service Health it says everything was good:
What to do in case of Azure Hiccups:
FIX: Re-run the task, hopefully it will fix the issue, like when you hit an old TV with your fist.
PREVENT: You can try to create an Activity Log alert but once again it will be based on Service Health (which says that everything is good) and not on the actual Activity Log. So you will probably miss issues like this and will discover the problem 24h later.
POST-MORTEM: You can take a screenshot of the failed task/service in the Activity Log, show it to Microsoft and ask for a refund if possible. For the future you can check the current status of Azure in the official Status page and subscribe to the RSS feed. You can browse the Azure Status History. But as I said none of the last two reports the Azure Hiccups so the screenshot of the Activity Log is still the only proof that a tree yesterday has fallen in the forest.
As Microsoft SLA says that the High availability for Azure SQL Database and SQL Managed Instance is 99.99% of the year you can start collecting those screenshot and open tickets with their support.
After dropping the Database this morning, the operation status of which was unsuccessful. The Restore has finally been canceled 8 hrs after attempting to drop the database.
Found a solution, just create a new database of the same name. And the restoring one will be replaced with the one created, then you can delete it.

Azure Database Migration Service stuck at "log shipping in progress"

I have a super small (no data, just a few single column tables, I'm just testing) on premise SQL server database that I'm trying to do an online migration for, to a SQL Managed Instance.
As far as I know I've configured everything as it should be - backup files are present in the file share, and the DMS is set up and can see both the SQL Server and the Managed Instance. However, it doesn't restore anything. It's stuck saying "log shipping in progress":
If I look at the managed instance itself, I can see a database has been created, and is currently in "Restoring" status.
My question is: how can I resolve this?
Maybe there are other logs I can look at, or there's some other permissions thing I don't know about, or something else?
I've tried creating a new project from scratch, but it had the same issue. And I've tried waiting... but I don't think it's working. As I mentioned, this is a DB with only a few tables (maybe 4), a single column in each table, no data at all.
Looking at your image, looks like there is no issue with DMS connecting to backup location and uploading backup and log files.
What is interesting is the field for last backup file applied and last applied LSN is empty. Makes me think there is some issue on the SQL MI machine.
I would recommend to open a case with MS Support on this.
One other thing you can try is to do a manual failover and your machine will failover to secondary node and then run the DMS job again.
https://techcommunity.microsoft.com/t5/azure-sql/user-initiated-manual-failover-on-sql-managed-instance/ba-p/1538803
Also try to take a look at what is going on with the SQL MI with any blocking.
You can use sp_whoisactive which is the latest version and it works on Azure SQL MI
https://github.com/amachanic/sp_whoisactive/releases/tag/v11.35
You need to assign permission to the service principal running the migration service at subscription level:
az role assignment create --assignee [YOUR SERVICE PRINCIPAL] --role contributor

Long Running Azure SQL Database Maintenance

There has been a previous question on this and the accepted answer was Azure Elastic Job agent. The problem I have is that the feature is in preview and it still lacks a lot of functionality like diagnostics and alerting. I also find it to be very unreliable as job get randomly cancelled because of service restarts.
Azure Automation Accounts also works, but it only has a execution/running time of 3 hours. So if your maintenance takes more than 3 hours, this is not an option.
I have previously developed my own application for doing this, but the maintenance and management of this can become a headache.
Another alternative could be to just leverage Azure Data Factory perhaps, but this is a route I have not yet followed.
So what are people actually using to do long running maintenance against Azure SQL Databases that has enough diagnostic information in case something goes wrong and has at least some level of alerting?
PS: The database I need to do maintenance on is not small.

Getting quite a few SQL Azure connection issues today, and forced disconnections, how to get more information from MS and also how to monitor?

We use the Northern Europe Azure Data Centre. We use SQL Azure Web Edition with Websites. Today we seem to be getting quite a few SQL Azure disconnections with error code 10054:
Symptom:
A transport-level error has occurred when receiving results from the server. An established connection was aborted by the software in your host machine
Mitigation:
Implement retry logic in your application
What is frustrating about this is that I cannot find any MS Azure Alerts to an issue. I suspect their SQL Azure systems will be ringing alarms. I have looked in Azure Status and Management Services.
Are there other places I can looks for these alerts, and also what is the best way to notify MS that there is an issue.
Finally how are folks monitoring SQL Azure for issues, throttling, disconnects etc? I have come across cotega.com.
P.s as a side note, I do understand the importance of putting in "retry logic", and but cannot happen quickly, and my code could be improved in this respect. However something does seem wrong with SQL Azure today. Up until now, the service has been by and large great.
EDIT 1:
Error Code:
Error Number:10054,State:0,Class:20
EDIT 2:
I think the moral of this story is to not underestimate the impact of throttling and scaling out, rather than scaling up, of SQL Azure services, and the importance of implementing retry logic/ MS Transient pattern logic. Still, this variable performance is a little frustrating, but perhaps this is the cloud for you, although with the new Data Tiers you can pay for more predictability.
EDIT 3: Interestingly SQL Azure is not performing more efficiently with no errors being noticed. So an issue with Azure. However difficult to identify apart from application error logs. I use Elmah.
Reconfigurations happen when upgrades are rolled-out to the service or when databases are load-balanced to avoid noisy neighbor issues.
The view sys.event_log in the master DB has information on why the disconnects happened (reconfiguration vs. throttling, etc.).
Service outages are reported in the portal.

Resources