简体   繁体   中英

MSMQ http\https Azure AD Authentication

I need to send an MSMQ message in c# through https to a web server using an Azure AD Bearer token.

The web server is hosted in Azure with Azure AD. The server is already hosting an existing web API in which we use Azure AD issued bearer tokens to authenticate. In the below link I'm not seeing a way to define custom authentication tokens with MSMQ.

https://blogs.msdn.microsoft.com/mismail/2008/12/31/msmq-over-http/

using (MessageQueue mq = new MessageQueue("...")
{
    Message msg = new Message
    {
        Body = request,
        Label = request.GetType().Name,
    };

    mq.Send(msg, MessageQueueTransactionType.Single);
}

That is because MSMQ over HTTP is just translating MSMQ protocol over HTTP. It is still MSMQ protocol. You cannot send MSMQ message to a generic Web API. You can only send MSMQ message to another MSMQ queue, which is configured to accept messages over HTTP using IIS. MSMQ is not a cloud technology and is not cross-platform technology (in terms it cannot send messages to anything other than MSMQ).

If you need to send your MSMQ messages to Web API / REST API that is hosted wherever, you have to use WebClient types or kind of REST Client to just sent requests and parse responses. You will have to deserialize the MSMQ message and serialize it to the format accepted by the WebAPI.

In addition you will need to obtain a bearer token, which is explained in small samples on the Microsoft Identity Platform samples page .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM