The remote server returned an error: (400) Bad Request.

I got this error while trying to back up the Azure SQL DB. The screenshot below is for your reference.

Backup to URL received an exception from the remote endpoint. Exception Message. The remote server returned an error (400) Bad Request.. (Microsoft.SqlServer.Smo)

The complete error message is as below

System.Data.SqlClient.SqlError: A nonrecoverable I/O error occurred on file “https://demostoragesql5.blob.core.windows.net/mynewdb/TSINFODB_backup_2021_01_12_151612.bak:” Backup to URL received an exception from the remote endpoint. Exception Message: The remote server returned an error: (400) Bad Request.. (Microsoft.SqlServer.Smo)

For help, click: https://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server& ProdVer=16.100.41011.9+(SqlManagementObjects-master-APPLOCAL)&LinkId=20476

Cause

When saving a blob file to a Non-Blob Storage or not using the Blob Storage Endpoint. SQL Server backups can only be saved to a Blob Storage. If you choose the Storage account as General Purpose Storage, you will have multiple endpoints for different usage.

Solution

To fix this error, You need to make sure the following stuff

While creating the Azure Storage account, If You select the Account kind as General Purpose. You will get multiple Endpoints for different purposes.

The remote server returned an error: (400) Bad Request.. (Microsoft.SqlServer.Smo)

Make sure to choose the correct endpoint. For example, if you are trying to store the SQL DB in blob storage, you should choose the Endpoint meant for Blob storage, not for other purposes like File, Queue, Table, etc.

Fix: SQL Backup to URL Error – The remote server returned an error: (400) Bad Request

You may also like following the articles below

Azure Virtual Machine

DOWNLOAD FREE AZURE VIRTUAL MACHINE PDF

Download our free 25+ page Azure Virtual Machine guide and master cloud deployment today!