This page shows an example below how you can use the utilities assembly to execute tasks to interact with service bus for admin activities.


var serviceBusNamespace = "AppFx-Test-@@LocalMachineName@@";
            string sasKey = "FP8jSHF7a+SLoaFuh6M1yQ/KNyebvfCy+PxE40lxL4Q=";
            string certPath = @"..\..\..\SBTesting.pfx";
            string subscriptionId = "{My Subscription ID}";
            string certificatePassword = "password";
            string connectionString = "Endpoint=sb://{0}.servicebus.windows.net/;SharedAccessKeyName=DevRule;SharedAccessKey={1}";
            string importEntitiesPath = @"..\..\..\SB_Entities.xml";
            string exportEntitiesPath = @"Export_Entities.xml";

            //Modify settings specific to dev box            
            serviceBusNamespace = Utilities.ServiceBusHelper.ModifyServiceBusNamespaceName(serviceBusNamespace);
            connectionString = string.Format(connectionString, serviceBusNamespace, sasKey);
            var managementCert = Utilities.ManagementCertificateHelper.LoadFromFile(certPath, certificatePassword);            
            
            Utilities.ServiceBusHelper.CreateNamespace(subscriptionId, serviceBusNamespace, managementCert, "North Europe");
            
            Utilities.SharedAccessSecretHelper.CreateFullSASRuleOnNamespaceRoot(subscriptionId, managementCert, serviceBusNamespace, "DevRule", sasKey);

            var serviceBusHelper = new Utilities.ServiceBusHelper(connectionString);
            serviceBusHelper.ImportEntities(importEntitiesPath);
            serviceBusHelper.ExportEntities(exportEntitiesPath);

            serviceBusHelper.DeleteAllNamespaceEntities();

            Utilities.ServiceBusHelper.DeleteNamespace(subscriptionId, serviceBusNamespace, managementCert);


Last edited Nov 14, 2013 at 12:56 AM by michaelstephenson, version 2