Wednesday 15 May 2013

c# 4.0 - How can I set the type of azure service bus to notification hub programmatically -



c# 4.0 - How can I set the type of azure service bus to notification hub programmatically -

using methods below, (until lastly week) create service bus "mixed" type , add together notification hub. however, stopped working. creates service bus "messaging" type , when tries create notification hub, error below:

enity xxxxxx, create notification hub failed error forbidden

public servicebusnamespaceresponse createservicebus(subscriptioncloudcredentials credentials, string regoin) { var servicebushubclient = cloudcontext.clients.createservicebusmanagementclient(credentials); var checkservicebusresponse = servicebushubclient.namespaces.checkavailability(_deploymentname); if (checkservicebusresponse.isavailable) { seek { var servicebusclientresponse = servicebushubclient.namespaces.create(_deploymentname, regoin); _servicebusendpoint = servicebusclientresponse.namespace.servicebusendpoint.tostring(); homecoming servicebusclientresponse; } grab (cloudexception ex) { console.writeline(ex.errormessage); homecoming null; } } homecoming null; }

and

public bool createnotificationhub(subscriptioncloudcredentials credentials) { sbnotificationhubmanager notificationhub; entitydescription servesbus = new entitydescription(); servesbus.name =_deploymentid; var des = new mynotificationhubdescription("push-hub-" + tenantid, servesbus); notificationhub = resourcefactory.get( _subscriptionid, new x509certificate2(convert.frombase64string(rowdata._base64encodedcert)), sbrestresourcetype.nhub, des) sbnotificationhubmanager; if (notificationhub != null) { // console.writeline("created notification hub: {0}{1}", environment.newline, notificationhub.lookup().tostring()); if (notificationhub.create()) { console.writeline("created notification hub: {0}{1}", environment.newline, notificationhub.lookup().tostring()); notificationhub.waituntillactive(); homecoming true; } } homecoming false; }

i wondering if changed in azure? can please advise how define type of service bus (messaging/notification hub) when creating in c#. default above method messaging. need mixed, notification hub type works fine in case.

thank you

now must explicitly select messaging (for topics/queues/event hubs) or notificationhub (for notification hubs). idea.

about implementation. observing source codes can see overload accepts servicebusnamespacecreateparameters argument:

task<servicebusnamespaceresponse> createnamespaceasync(string namespacename, servicebusnamespacecreateparameters namespaceentity, cancellationtoken cancellationtoken);

that class has public property of namespacetype

public namespacetype namespacetype{...

so set namespacetype.notificationhub , go ahead create namespace.

c#-4.0

No comments:

Post a Comment