How to control NServiceBus queue name when hosted on Azure? - c#

For some reason the queue hosted on windows azure is not respecting the .DefineEndpointName() configuration.
The queue name on Azure Bus is always named after the worker role that's hosting it. While this is fine, in general, I'd feel a lot better if there was an option to manually override the convention.
How can I define my own queue name?

There is a configuration setting that can be used to control the queue name:
You can add it to your service configuration files like this,
<Setting name="AzureQueueConfig.QueueName" value="yourqueue" />
Or add it in app.config like this:
<AzureQueueConfig QueueName="yourqueue" />
PS: Define endpoint name should work as well, can you reproduce the issue in a small sample and file it as an issue on https://github.com/nservicebus/nservicebus
Thanks,
Yves

Related

Change xmlSerializer tempFilesLocation for a wcf client

We use WCF client in our project which is an Azure functions app, to communicate with an external web service. We need to change the xmlSerializer's tempFilesLocation because of the permission issue. I searched online and found the following configuration that we can use in our web.config which will solve the problem.
<system.xml.serialization>
<xmlSerializer tempFilesLocation="an absolute path of your choice"/>
</system.xml.serialization>
But in Azure Functions app, we don't have access to web.config, so we need to find a way to do it in the code. Is there any way to change tempFilesLocation in the code?
It's not possible to modify the web.config for functions running on the dynamic sku (where you pay-per-invocation).
However, if you create your function on the non-dynamic/classic sku (where you pay per vm, the pricing model for regular web apps) then you can modify the web.config settings via an applicationHost.xdt file. More details on how to work with xdt file here: https://github.com/projectkudu/kudu/wiki/Xdt-transform-samples

Azure Slot Swapping: Configure WCF endpoint in Azure

I want to use Slot Swapping on Azure for a WCF Service. I know that we can do the appSettings directly in Azure. I couldn't find an option to configure the system.serviceModel/client, but for slot swapping i need 3 endpoint configurations, one on each slot I have
<system.serviceModel>
<client>
<endpoint address="http://myservice-devslot.azurewebsites.net/ServiceName.svc" ... />
</client>
This would be the configuration for 1 slot, as it's shown in the address: dev-slot
Or is there an other approach to manage endpoints?
Ok, I configured the endpoint address through Code and added an EndPointAddress Key to the AppSettings. Now I can swap from TEST to INT etc by just do one click in Azure. Thanks everyone
wcfServiceClient.Endpoint.Address = new EndpointAddress(endPointAddress);
For editing config files depending on the destination environment you're going to deploy the application to, you'd usually use config transformations.
As you're looking to so using azure, have a look at this article by Brady Gaster as starting point. It describes the whole procedure quite detailed.

Load DataCache from Role Entry Point On Start

I want to access my windows Azure Data Cache from my Role Entry StartUp routine. However I keep getting this error:
{"ErrorCode:SubStatus:Server collection cannot be empty."}
However when I do the same from within my Controller class it loads the Data Cache fine and I can go ahead and do things with it.
Is there anything special for the Role Entry class that I have to do to access the Data Cache prior to my application starting?
Or can't I access the Cache in the Role StartUp ?
Cheers
Starting with Azure SDK 1.3, there is a major change - the Full IIS mode. Read this blog post to get full undertanding of full IIS and what is it.
In short - your RoleEntryPoint descendant (where your OnStart method is being executed) lives in whole another AppDomain (and process actually - WaIISHost.exe), while your actual web application just lives in IIS (w3wp.exe). That's why there is no way to do something in OnStart() that would affect your web applicatin or that would be able to directly read your web.config.
If you do read Azure Data Cache in OnStart to do some preload of data for the web application, just do in your Global.asax's Application_Start() event handler.
If you need to read Azure Data Cache in OnStart for reason's specific to the RoleEntryPoint, you have to load the configuration from web.config. Web.config is placed in "./bin/web.config" relative to your AppRoot folder. (there are two copies of your application when you use WebRoles with full IIS - one lives in AppRoot and one lives in SitesRoot).
Hope this helps!
WebRole's OnStart probably does not use your web.config where you probably have specified server names and access keys for your AppFabric DataCache provider.
I would try manually instrumenting the server connection configuration.

Log4Net out of a IIS Hosted WCF Service

Good day folks
I must have read about 20 different articles/approaches about how to implement log4net in ASP.NET 1.0 / 2.0 and various other application types.
Link #1
Link #2
Link #3
Well, above articles are all ok, i did try/follow all of them, but i never got a log file..
What i have:
IIS Hosted WCF Service.
What i want:
Logging using log4net - well, first i wanted to use Tracing (like Trace.Write in System.Diagnostics) then the Microsoft Enterprise Library and finally i'm stuck trying to figure out how to setup/configure log4net for my logging needs.
My question:
How to get log4net writing a logfile? i mean:
- is it a security problem? do i really need to procmon this?
- is the problem to write to a log file (security)?
- is the problem that the configuration file cannot be read?
i tried:
Specifying the log4net.config using
[assembly: log4net.Config.XmlConfigurator(ConfigFileExtension = "log4net.config", Watch = true)]
Specifying the configuration in web.config after the block. When i did that i wasn't able to run the Web Application anymore (IIS reports corrupt web.config).
Help in this issue is really appreciated!
Christian
Ok, my fault. It was the declaration when ConfigFileExtension is declared, log4net searches for .dll. in the web root. Just changed that to ConfigFile and it's working like a charm. my careless mistake...!
Christian

Forcing WcfSvcHost.exe to use my custom service host

Is it possible to force WcfSvcHost (which is executed automatically when I do an F5 or when I am debugging another project in the solution) to use a custom ustom service?
I have my custom service host working great in my asp.net Host container by using a service factory which in turn calls the Custom Service Base.
But when WcfSvcHost executes it's not using my custom ustom service.
Is this possible?
If not, what are my alternatives? I presume I must uncheck "Start WCF service host when debugging a project in another solution" which is in the WCF Options in app properties but then I must create a console Host container?
And I can't get the console host container to automatically execute each time I am debugging something else?
I notice this under DEBUG in app properties (maybe I can use something like this to force the loading of the custom servicehost)
/client:"WcfTestClient.exe"
The problem being is that I have my custom ServiceHost inject some UNITY (IOC) stuff, here the overriden method ... so it must execute otherwise it fails.
protected override void InitializeRuntime()
{
Bootstrapper.ConfigureUnityContainer();
base.InitializeRuntime();
}
I was trying exactly the same thing for exactly the same purpose (;-)
I thought I found a solution by not using physical .svc files anymore (which contain the custom host factory when hosting in IIS), but moving this info to the .config file instead:
<serviceHostingEnvironment aspNetCompatibilityEnabled="false">
<serviceActivations>
<add relativeAddress="~/Services/NaisTime/NaisTimeService.svc" service="Nais.Time.Services.NaisTime.NaisTimeService"
factory="Nais.Time.Services.NaisServiceHost.NaisServiceHostFactory, Nais.Time.Services" />
<add relativeAddress="~/Services/Northwind/NorthwindService.svc" service="Nais.Time.Services.Northwind.NorthwindService"
factory="Nais.Time.Services.NaisServiceHost.NaisServiceHostFactory, Nais.Time.Services" />
</serviceActivations>
</serviceHostingEnvironment>
It works for IIS, but putting the same entries in the app.config file of my Service Library project does not make SvcWcfHost use this.
I guess I am not getting my relativeAddress right.
Anybody any experience with this?
kr,
Michel Liesmons.
I don't think you can do that - you'll need to host in IIS or create your own, customized service host.

Categories

Resources