Is there any attribute in the message header which indicates that the message is from a Create request or Update request?
Question relates to Azure service bus and I think there is no such way (as per my understanding).
Now coming to your requirement, you need create message from crm to go on Create Topic (service bus) and same way with Update message. This can be achieved, you will have to register plugin on create and update trigger for particular entity in crm. In this plugin you will have to connect with your Azure service bus correct topic which you want with SASKey (there are numerous examples) and push the crm message to your service bus topic.
below pseudo code for understanding to send object to service bus. please don't take as it is, just to show this can be achieved and we did this in one of our project.
public bool SendObjectToBus<TBusObject>(TBusObject serializedObject, HttpMessageHandler messagHandler = null)
where TBusObject: IBusObject
{
if (string.IsNullOrEmpty(_sasToken) || validUntil >= DateTime.UtcNow - new DateTime(1970, 1, 1))
{
_sasToken = GetSasToken(new TimeSpan(0, 0, 90));
}
string json = JsonSerializer.Serialize(serializedObject);
HttpClient client = messagHandler == null ? new HttpClient() : new HttpClient(messagHandler);
client.DefaultRequestHeaders.Add("Authorization", _sasToken);
using (var Content = new StringContent(json, Encoding.UTF8, "application/json"))
{
_headerContext.AddHeaders(Content.Headers, ApiSettings.EnvironmentType);
//this._tracingService.Trace("Sending Message to Servicebus");
var response = client.PostAsync(ApiSettings.GetTopicURL(), Content);
response.Wait();
return response.Result.IsSuccessStatusCode;
}
//this._tracingService.Trace("Message sent");
//this._tracingService.Trace(response.Result.StatusCode.ToString());
}
private string GetSasToken(TimeSpan validRange)
{
TimeSpan sinceEpoch = DateTime.UtcNow - new DateTime(1970, 1, 1);
validUntil = sinceEpoch + validRange;
string expiry = Convert.ToString(validUntil.TotalSeconds);
string stringToSign = Uri.EscapeDataString(ApiSettings.ServiceBusNamespaceUrl).ToLowerInvariant() + "\n"
+ expiry;
HMACSHA256 hmac = new HMACSHA256(Encoding.UTF8.GetBytes(ApiSettings.SASValue));
var signature = Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(stringToSign)));
var sasToken = string.Format(CultureInfo.InvariantCulture, "SharedAccessSignature sr={0}&sig={1}&se={2}&skn={3}",
Uri.EscapeDataString(ApiSettings.ServiceBusNamespaceUrl).ToLowerInvariant(),
Uri.EscapeDataString(signature),
expiry,
ApiSettings.SASKey);
return sasToken;
}