How to configure Kentico CMS to use In-Role Cache - c#

First of all, I'm new to Kentico CMS.
We download the from here. Then install the application as Windows Azure project.
When I look at web.config, Kentico CMS 7 (as of today) uses Shared Caching which has been deprecated a couple of years back.
Is there any way I can configure to use In-Role Cache (or worst case Cache Service which is still in Preview)?
<!-- Azure AppFabric cache BEGIN -->
<section name="dataCacheClients"
type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection,
Microsoft.ApplicationServer.Caching.Core" allowLocation="true"
allowDefinition="Everywhere"/>
<!-- Azure AppFabric cache END -->
<!-- Azure AppFabric cache BEGIN -->
<dataCacheClients>
<dataCacheClient name="default">
<hosts>
<host name="YourName.cache.windows.net" cachePort="22233"/>
</hosts>
<securityProperties mode="Message">
<messageSecurity authorizationInfo="YourKey"/>
</securityProperties>
</dataCacheClient>
<dataCacheClient name="SslEndpoint">
<hosts>
<host name="YourName.cache.windows.net" cachePort="22243"/>
</hosts>
<securityProperties mode="Message" sslEnabled="true">
<messageSecurity authorizationInfo="YourKey"/>
</securityProperties>
</dataCacheClient>
</dataCacheClients>
<!-- Azure AppFabric cache END -->

The host element in the caching configuration points to a caching cluster and it doesn't care about how the cache cluster is deployed - old service, new service or in-role.
If you use the new Caching service you should be able to change the configuration to point at your cache instance using your cache's URL
To use in-role caching you will need to create the relevant load-balanced endpoints for the cloud service and then configure your client with your cloud service URL.

I found the article in Kentico site, so I posted for others -
Windows Azure Cache Service in Kentico CMS
If you used AppFabric caching in your Kentico CMS projects running on Azure, you could be interested in replacing this caching option with a new Windows Azure Cache because AppFabric cache is no longer provided.
To make it work, you should follow the official guide from Azure documentation - How to Use Windows Azure Cache Service (Preview).
After initially creating the cache and configuring it, you need to open your project in Visual Studio and install Windows Azure Caching NuGet package for CMSApp web role as it is mentioned in the guide.
Another step is to remove xmlns attribute from tag in your web.config file, replace the original and tags with the newly added ones and delete duplicate tag.
The next thing to do is to remove xmlns attribute for tag as well, put tag to the original section and delete the duplicate.
The rest of the steps should correspond to those mentioned in the guide, i.e. replacing [Cache role name or Service Endpoint] with the endpoint, which is displayed on the Dashboard in the Azure Management Portal.
The guide also contains sample codes for creating and retrieving objects from the cache, specifying expiration, storing ASP.NET session state, etc.

Related

How to enable EnableSqlCommandTextInstrumentation via code?

According to the documentation you need to add the following to your applicationInsights.config file to enable full SQL logging:
<Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">
<EnableSqlCommandTextInstrumentation>true</EnableSqlCommandTextInstrumentation>
</Add>
But in my ASP.NET app running on .NET Framework 4.7.2 hosted in an Azure App Service I'm enabling/configuring Application Insights via code:
TelemetryConfiguration.Active.DisableTelemetry = false;
TelemetryConfiguration.Active.InstrumentationKey = setting.ApplicationInsightsInstrumentationKey;
How can I enable this setting via code?
P.S.: The settings in the Web App are correctly enabled.
It seems even if AI is enabled via code it picks up the settings from the config file.
I added it to my applicationInsights.config and it seems to work now.

How to manage custom section from Web.Config in Azure App Settings?

I have this custom section in my web.config
<defaultUserAccounts>
<userAccount email="x#x.com" password="xxx" />
<userAccount email="y#y.com" password="yyy" />
</defaultUserAccounts>
I host my web app on Azure and I want to be able to add new userAccount in the Azure App Settings.
I tried with:
defaultUserAccounts.userAccount.email / z#z.com
defaultUserAccounts.userAccount.password / zzz
OR
defaultUserAccounts:userAccount:email / z#z.com
defaultUserAccounts:userAccount:password / zzz
But it doesnt work. I can read the web.config custom section in localhost, but not when the app is hosted.
Could you help me?
You can only write the app settings using the management API of Azure. See here for an example using the Fluent SDK. Otherwise the settings are read-only from within the app.
https://stackoverflow.com/a/50116234
If you don't want to configure app setting in the Configuration you could follow this tutorial:Configure app settings configure it under tag <appSettings> in Web.config, but the values in App Service override the ones in Web.config.
The below is my test:
And use System.Configuration.ConfigurationManager.AppSettings["testkey"] to get the value, the below page is get the value with host in Azure.
Hope this could help you.

Error in Angular app running on .NET Core in Service Fabric

I have created a new service fabric application, added a stateless .NET Core service (.NET Core 2.1) and selected the angular template. It builds fine and all looks OK however when I run it I get this error:
Startup.cs contains a line spa.UseAngularCliServer(npmScript: "start"); which is only used in development, if I remove this line then I no longer get this error but it doesn't pick up any of my changes to code.
I have tried updating my npm, node, angular cli versions, updating the project to angular 7 (it is 5 by default) with no luck.
If I run ng serve directly in the ClientApp folder it runs OK so the issue seems to be to do with it being hosted in .NET Core or SF.
It seems it could be something to do with the SF service not having permissions to create/edit files/folders under system32?
As suspected it was to do with SF not having permission to modify that folder. Service fabric runs under the user NETWORK SERVICE.
I found 2 ways to fix it:
1. Manually grant permission to NETWORK SERVICE
I navigated to C:\Windows\System32\config\systemprofile\AppData\Roaming and edited the permissions in that folder to give the user NETWORK SERVICE permissions to read/write
2. Edit ApplicationManifest.xml to give SF admin permissions
By adding
<Principals>
<Users>
<User Name="LocalAdmin" AccountType="NetworkService">
<MemberOf>
<SystemGroup Name="Administrators" />
</MemberOf>
</User>
</Users>
</Principals>
<Policies>
<DefaultRunAsPolicy UserRef="LocalAdmin" />
</Policies>
Either of these seems to make it work. The best part is all it eventually did is create an empty npm folder there.

EPiServer 8 shared VPP folder

i want to configure multi-developer development environment for a web site in EPi server 8. i have followed this article to do this(i guess that's the only article provided on web for this purpose :-) )
i have moved my EPi Server database and VPP folder(Modules/_protected) to a shared location
I have changed following physical paths web.config
<episerver.packaging protectedVirtualPath="~/EPiServer/" protectedPath="\\location\Modules\_Protected" publicVirtualPath="~/modules/" publicPath="modules" />
<virtualPathProviders>
<clear />
<add name="ProtectedModules" virtualPath="~/EPiServer/" physicalPath="\\location\Modules\_Protected" type="EPiServer.Web.Hosting.VirtualPathNonUnifiedProvider, EPiServer.Framework" />
</virtualPathProviders>
I have restarted IIS as well but still website tries to access EPiServer.Cms.Shell.UI.zip from old location which is [websiterootfolder]\modules_protected\CMS
Can anyone please help????

Azure: getting service certificate without defining an additional configuration

My cloud service has the following config:
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration ...>
<Role name="...">
<ConfigurationSettings>
<Setting name="MyCertThumbprint" value="AB687DC9F63D51AE6E9522B86B97EFD15F55EA42" />
</ConfigurationSettings>
<Certificates>
<Certificate name="MyCert" thumbprint="AB687DC9F63D51AE6E9522B86B97EFD15F55EA42" thumbprintAlgorithm="sha1" />
</Certificates>
</Role>
</ServiceConfiguration>
See the redundance?
I want to get rid of MyCertThumbprint config. Is there an Azure API that gives me access to the thumbprint of MyCert? Or maybe the X509Certificate2 instance itself (i.e. without having to search for it using X509Store) ?
Sure - if you know other information about the certificate, you can use any of the X509FindType Enumerations with X509Certificate2Collection.Find Method. Unfortunately, the Certificates section of the ServiceConfiguration is for locating the certificate in the Cloud Service certificate store and installing that certificate on the VMs associated with the Role you are deploying. There is no API to access the section directly. So your choice is to hard code something like the certificate subject name or the thumbprint and hope it doesn't change, or add a setting like you've demonstrated in your code sample that is configurable with each deployment.
The ConfigurationSettings section mirrors the appSettings section in the web.config file and when used in conjunction with CloudConfigurationManager.GetSetting("settingsKey") with look first in the ServiceConnfiguration then in the web.config for application settings, allowing you to un local in an emulator or just IIS express and achieve the same functionality. So we duplicate the settings in both ServiceConfiguration and web.config.

Categories

Resources