I have an Azure WebSite project with WebJob project accosiated with it. The WebJob project needs to connect to external SOAP service. AS a result I have to put in the app.config the following block:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_MyExternalClassName">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="<<external URL>>" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_MyExternalClassName" contract="xxxxx" name="WSHttpBinding_MyExternalClassName" />
</client>
</system.serviceModel>
The problem is that I need to change value of <<external URL>> in "endpoint" node for different deployment scenarios - testing and production.
WebJob SDK seems to take Connection strings and app settigns from parent application, but what abount this specific SOAP-related service setting ?
How can I manage testing/production scenario?
Put the soap URL appSettings section inside web.config. Then read it using ConfigurationManager or CloudConfigurationManager. Obviously you have to manually set the url in code when you create the wcf client.
<appSettings>
<add key="soapurl" value="http://..." />
</appSettings>
Related
I have a Web App that I deploy via YAML pipeline, but would like to see if it can be done via web app's Deployment Center.
I need to transform the IP address and userPrincipalName in the endpoint element, but it does not fall under AppSettings or connectionstring element. Is it possible to transform this kind of element via Web App, or am I stuck with YAML pipeline?
Here is snippet of my config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="API_AUTH_MODE" value="2" />
</appSettings>
<system.serviceModel>
<client>
<endpoint address="net.tcp://10.0.0.0:99/App1/Services/Service1"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Service1"
contract="Service1" name="NetTcpBinding_Service1">
<identity>
<userPrincipalName value="user#domain.local" />
</identity>
</endpoint>
<endpoint address="net.tcp://10.0.0.0:99/App1/Services/Service2"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Service2"
contract="Service2" name="NetTcpBinding_Service2">
<identity>
<userPrincipalName value="user#domain.local" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
Is it possible to transform this kind of element via Web App, or am I stuck with YAML pipeline?
AFAIK, I am afraid you could not transform this kind of element via Web App at this mpment.
That because the IP address and userPrincipalName does not fall under AppSettings or connectionstring element.
So, we could not use the Application settings or connection strings to replace it. We have to resolve this issue with YAML pipeline.
BTW, we could use the Replace Tokens in the YAML pipeline to resolve it.
Hope this helps.
While it was answered correctly above - Web App cannot transform anything other than Appsettings or 'connectionstring`, I ended up doing the following:
Use XML Transform files to replace the strings needed, since there is dependency on build type
Use YAML file to access vault to do password replacements.
I could have used Web App to do the password replacements, but it is much easier to manage the pipeline/deployment/release via a single YAML file rather than split YAML and Web App.
Im uploading images to azure blob storage in a project. For logic reason I'm creating a new container for each upload, to group the content. This park works fine. Now I'm trying to setup ImageResizer to enable resizing :) and som other stuff. In all the examples they point to a container as the endpoint, but in my case I have multiple dynamic container, so this is not an option. My question is if someone knows if it should work in my case or if I need to rethink something about the way I store images.
According to your requirement, you could try to leverage AzureReader2 to work with Azure blobs, in order to dynamic resize your images from Azure Blob. Since you have miltiple dynamic containers, you could follow the steps below to configure AzureReader2:
Install Package via NuGet
ImageResizer.WebConfig
ImageResizer.Plugins.AzureReader2
Web.config
<configSections>
<section name="resizer" type="ImageResizer.ResizerSection" requirePermission="false" />
</configSections>
<resizer>
<plugins>
<add name="MvcRoutingShim" />
<add name="AzureReader2"
connectionString="{your-storage-connectionstring}"
prefix="~/cloud/" />
</plugins>
</resizer>
<system.web>
<httpModules>
<add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
</httpModules>
</system.web>
<system.webServer>
<modules>
<add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
</modules>
</system.webServer>
Result
Here is my test, you could refer to it.
1.Upload images to my Azure Blob
https://brucechen.blob.core.windows.net/images01/test.jpg
https://brucechen.blob.core.windows.net/images01/landscape/test.jpg
https://brucechen.blob.core.windows.net/images02/test.jpg
2.Browser images in my web site as follows:
http://bruce-chen.azurewebsites.net/cloud/images01/test.jpg?width=400
http://bruce-chen.azurewebsites.net/cloud/images01/landscape/test.jpg?width=400
http://bruce-chen.azurewebsites.net/cloud/images02/test.jpg?width=400
Note: your images links should look like:
http(s)://<host-name>:<port>/<prefix-you-configured>/<blob-container-name>/<blob-file-name>?width=200&height=200
Additionally, for pre-resizing your images via ImageResizer, you could follow the answer in this thread. Also, there is anther similar library called Simple.ImageResizer which is free, you could refer to it.
When using NServiceBus the Transport connection string doesn't seem to be fetched from the applicable Cloud configuration first but immediately from the app.config.
Options I've tried:
Using the configuration section (:
cscfg
<ConfigurationSettings>
<Setting name="AzureServiceBusQueueConfig.ConnectionString" value="Endpoint=sb://xxx.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yyy" />
</ConfigurationSettings>
app.config
<AzureServiceBusQueueConfig ConnectionString="Endpoint=sb://xxx.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yyy" />
Using a custom connection string name:
cscfg
<ConfigurationSettings>
<Setting name="NServiceBus.Transport" value="Endpoint=sb://xxx.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yyy" />
</ConfigurationSettings>
app.config
<connectionStrings>
<add name="NServiceBus.Transport" connectionString="Endpoint=sb://xxx.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yyy"/>
</connectionStrings>
Also tried to override it by using the following line of code, since this issue is still open (https://github.com/Particular/NServiceBus.AzureServiceBus/issues/20):
configuration.UseTransport<AzureServiceBusTransport>().ConnectionString(CloudConfigurationManager.GetSetting("AzureServiceBusQueueConfig.ConnectionString"));
Or tried to set the connection string name manually, which works again using the app.config but doesn't let the cscfg override.
configuration.UseTransport<AzureServiceBusTransport>().ConnectionStringName("NServiceBus.Transport");
Did you turn the azure configuration source on? You can do so using following extension method on the bus configuration:
.AzureConfigurationSource()
I've got the Redis Session State Provider working fine locally with my ASP.Net site and in Azure with my Azure Website. But I've got a question about configuration...
Is there any way to store the configuration for that in the Azure Website itself using the App Settings (or Configuration Strings) section in the Website Properties screen?
That would be very convenient because it would mean that I don't have to modify the web.config file when I publish. I already do this for connection strings and app settings, but I just don't see a way to do that for anything in the <system.web> node of the web.config file, like the <sessionState> node.
There isn't a way to change the behaviour of the provider-based session state from utilising the web.config file.
You could write your own provider and modify where it finds the connection details from so you can publish those details somewhere other than in the web.config, but this wouldn't be standard behaviour.
This question has the way to make this work.
<appSettings>
<add key="REDIS_CONNECTION_STRING" value="[your dev connection string]" />
</appSettings>
<system.web>
<sessionState mode="Custom" customProvider="RedisProvider">
<providers>
<add name="RedisProvider" type="Microsoft.Web.Redis.RedisSessionStateProvider" connectionString="REDIS_CONNECTION_STRING" />
</providers>
</sessionState>
</system.web>
Then, in the portal, you can create an app setting with the name 'REDIS_CONNECTION_STRING' with the correct connection string. You cannot use connection strings section of web.config or azure portal. It must be app settings. Not sure why, but connection strings just uses whatever is in the web.config and is not replaced with what is in the portal.
After I published my azure cloud service to azure, I got as result the following:
Do you know what the problem is? I am using asp.net 4.0 mvc razor. I think, it doesn't load the webconfig.
You don't have a Default.aspx. You can either add a Default.aspx, or you can modify the web.config's <defaultDocument> property.
You can have following configuration in web.Config -
<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value="HtmlPage1.html" />
</files>
</defaultDocument>
<directoryBrowse enabled="false" />
</system.webServer>
</configuration>
And in RoutesConfig.cs -
routes.IgnoreRoute("");
Having IgnoreRoute() will make ASP.Net to fetch the default document specified in the web.config, instead of Routes engine to process route. And defaultDocument tag will make that file to be served for default URL "/".
I took the solution to take a Azure Website and not a Web Role and it works :)