Posts

How to delete duplicate records from a table by using a CTA in SQL Server

You can use a CTA (Common Table Expression) to delete duplicate records from a SQL Server table by writing a statement like this;
WITH Location_CTE AS(SELECT [Id],[LocationQuery],[DetailsResponseJson],[DateCreated],[DateUpdated],ROW_NUMBER()OVER(PARTITIONBY[LocationQuery]ORDERBY[LocationQuery]) Row_NumFROM [dbo].[Location])DELETEFROM Location_CTEWHERE

Umbraco V8 Upgrade from V7 - Developer Notes

Image
Recently I have started working on upgrading my client's Umbraco v7.15.4 website to Umbraco v8.6.3 (current latest version) and decided to write this blog as it can be very tricky and you might end up spending hours if not days to fix your problems. I'd be very happy if I can help you to save some time and do better planning before doing your upgrade.
Before you start doing anything, you should know that; Umbraco 8 is a major release. There will be a lot of breaking changes, for my case 435 new features, 95 breaking changes and 1254 issues & tasks.Please check the local development and hosting requirements, otherwise the upgrade will fail and you have to rollback your changes to try again.One important thing, please make sure you have done all your Visual Studio 2017 or 2019 upgrades first.Ensure that you have got .NET Framework 4.7.2 installed.Upgrade your v7 Umbraco project to 7.14+, latest v7 version would be your best option.Umbraco codebase has been fundamentally update…

Postman - Useful Queries for Azure Search Service

Search by text

https://YOUR-AZURE-SEARCH-SERVICE-NAME.search.windows.net/indexes/YOUR-AZURE-SEARCH-INDEX-NAME/docs?search=cbt&api-version=2016-09-01&$count=true https://YOUR-AZURE-SEARCH-SERVICE-NAME.search.windows.net/indexes/YOUR-AZURE-SEARCH-INDEX-NAME/docs?search=kerr&api-version=2016-09-01&$count=true
Top&skip https://YOUR-AZURE-SEARCH-SERVICE-NAME.search.windows.net/indexes/YOUR-AZURE-SEARCH-INDEX-NAME/docs?api-version=2016-09-01&$top=3&$skip=0&$count=true
Facets - postman https://YOUR-AZURE-SEARCH-SERVICE-NAME.search.windows.net/indexes/YOUR-AZURE-SEARCH-INDEX-NAME/docs?api-version=2016-09-01&$count=true&facet=specialisms
Facets - return all facets https://YOUR-AZURE-SEARCH-SERVICE-NAME.search.windows.net/indexes/YOUR-AZURE-SEARCH-INDEX-NAME/docs?api-version=2016-09-01&$count=true&facet=specialisms, count:9999&facet=clientele, count:9999&$filter=listingType eq 'Therapist'
Return everything and count(*) for YOUR-AZURE-SEARCH…

How to Setup Custom Umbraco Error Pages per HTTP Status Error Code (e.g: 400, 401, 403, 404, 500, etc.)

In order to create human friendly content editable custom error pages for an Umbraco project, below are the steps that you can follow;

In your web.config (system.webServer section), add the following setting to tell the site to pass all of the error handling through you application:<httpErrorsexistingResponse="PassThrough" /> Add the httpErrors - this is an IIS level setting rather than an ASP.NET setting, therefore, this needs to go into the system.webServer section in the web.config:<system.webServer>
…     <httpErrorserrorMode="Custom"existingResponse="Replace">       <clear/>       <error statusCode="400" path="/error-pages/http-errors/400/" responseMode="ExecuteURL"/>       <error statusCode="401" path="/error-pages/http-errors/401/" responseMode="ExecuteURL"/>       <error<

Data Parallelism (Task Parallel Library) with MaxDegreeOfParallelism set as ProcessorCount

It could be beneficial to run multiple threads to perform operations on different segments concurrently, so that certain tasks can be completed quicker (like some data updates using some services), and Data Parallelism  could help you, and in this scenario you can benefit from a powerful processor by writing a code as follows;


ParallelOptions options = new ParallelOptions() { MaxDegreeOfParallelism = System.Environment.ProcessorCount };
Parallel.ForEach(mdList.AsEnumerable(), options, async row => {    result = await ProcessATask(param);
});
For debugging purposes; you can replace the ParallelForEach with this following line to your checks for certain items;

Parallel.ForEach(mdList.Select(“numbertocheck”).AsEnumerable(), options, async row => {    result = await ProcessATask(param);
});


KUDU - Easily Removing Items from wwwroot

Image
It is possible that after some big code changes(i.e. a big upgrade), you might have some issues with some old dlls, and in order to prevent some unexpected problems, you might want to remove everything under your Web App's wwwroot(or any other folder), and if this is the case, then you can Kudu for Azure Web Apps;
Login to Azure Portal with your project's Azure credentials.Find your Azure Web App and copy its url and write the following command to remove all items from wwwroot.Get-ChildItem 'D:\home\site\wwwroot' | Remove-Item -Recurse -ForceAfter doing this, you shouldn't see anything under wwwroot and you can then start your clean deployment(swap for my case).

How to use KUDU to check Azure App Service OS version

Kudu is the engine behind git deployments in Azure Web Site and it can also run outside of Azure. Please click here for more details.

Kudu can be used to find out an Azure App Service's OS version and all of other details like other environmental details etc. and here are the steps to check the OS system of you App Service;
Login to Azure Portal with you credentials, and find your App Service.Find the publishUrl of your App Service, it should be something like this;your-app-name.scm.azurewebsites.net:443Now simply go to this url; https://your-app-name.scm.azurewebsites.netIn the Environment page, under System info, you will find the details for your system, including your Azure App Service's OS version. Hope it helps.