Hello Spencer Thompson (Network),
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you are unable to send a Service Bus Message from Sql Server with a newly set up credential and queue.
The below should solve the issue:
- Open Master Key:
OPEN MASTER KEY DECRYPTION BY PASSWORD='<yourPassword>';
- Create Scoped Credential:
CREATE DATABASE SCOPED CREDENTIAL [https://<serviceBusName>.servicebus.windows.net/<queueName>]
WITH IDENTITY = 'Managed Identity',
SECRET = '{"resourceid":"https://servicebus.azure.net"}';
- Send Message:
DECLARE @response NVARCHAR(MAX);
DECLARE @url NVARCHAR(4000) = N'https://<serviceBusName>.servicebus.windows.net/<queueName>/messages';
DECLARE @Guid NVARCHAR(40) = NEWID();
DECLARE @payload NVARCHAR(MAX) = '{ "message": "Hello, world! ' + @Guid + '" }';
EXEC sp_invoke_external_rest_endpoint
@method = N'POST',
@url = @url,
@credential = [<serviceBusName>.servicebus.windows.net/<queueName>],
@payload = @payload,
@response = @response OUTPUT;
PRINT @Guid + ' ' + @response;
I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.