Just Sitecore Things

Sitecore tips and tricks and community news !

Post Top Ad

Post Top Ad

Monday, October 28, 2019

7:02 PM

Automating SPE SXA sites cloning

Multisite approach is well known topic for all Sitecore guys. Not even for them (or us I should say :)), but also for also for marketing guys and every person which has connections with managing a big site.

Today I would like to say more about creating multisite solution in context of SXA. Each of us who worked with SXA had an opportunity to see cloning mechanism in Sitecore content editor which we can achieve from context menu. For everyone else it's look like:


When we are starting developing usually we operating with one site, which we are extending. But then come a moment when client needs more than one site. There is no a problem when we have to make 1,2 or 3 sites more. But question what if we need to create e.g. 25 new sites? Would you like to make it manually? :)
Moreover we can assume that it has to be done on more then one environment. It going to extend time or preparation this by manual work many times.

Answer for this issue and solution is to automate this action. As we hear many times, if you have to do something more than once, you should to automate this.

Basing on that and on SXA we can start to digging and creating a solution to make it happen!

Cloning site with SXA is nothing else than use already prepared Powershell scripts from SXA guys, which this cloning make true. Hence, we as a developers can use those scripts and make more complex and useful for us.

Scripts which are out of the box we can find here:


As you can see there is more scripts than we are looking for. Maybe it will be useful for you in the future. At this moment we will focus on SXA scripts and their cloning sites mechanism which are a bit below than last image shows.They are exactly here:
 
As we see, we have functions like "Copy-Site" or "Clone Site" which position which aggregates a functions from below node and represents context menu option. Let's check how does it look inside, what we can find here:

to better understanding lets put it in VS Code:


At first look we see usage of internal functions, managing dialog box etc. So right now we don't have any obstacles to make it something on our own.

Firstly let's think a bit and answer on question: How we will pass data to our new script? An idea could be prepare some csv file which you will iterate and in that way create as many sites as you want to have.

Additionally we can do some improvements and create already some languages, some accounts for new sites needs. In my example we have also some nodes aggregating sites to regions, but of course it is not necessary.
In that way we can define columns and below rows with values:

Then we can start to create some functions on our own which we will put to Modules and scripts nodes later in Sitecore. It will be done in the same way as e.g. SXA catalog is prepared but of course you can create you own catalog to make better separation. Take a look on below script. There you will find options for setting page designs etc. Maybe it will be some inspiration for your cases as well.
I hope so :) Enjoy !
Cheers !

Tuesday, September 17, 2019

1:55 PM

Sitecore + SXA + xCommerce - Azure ASE custom ARMs deployment

Hello fellows,

Today I would like to talk about custom deployment of Sitecore 9.0.2 + SXA  + xCommerce  on Azure PaaS - but here we have to add something more ASE support. I got a case from client to make it in isolated way and this approach was the most acceptable by them.

Because they have used Sitecore 9.0.2 we have to work with this version, which needs our custom work to achieve Azure ASE on Sitecore ARMs files.



But somebody will ask, bro, what is this Azure ASE?

From MS site (more Microsoft Docs - Azure ASE):

The Azure App Service Environment is an Azure App Service feature that provides a fully isolated and dedicated environment for securely running App Service apps at high scale. This capability can host your:
  • Windows web apps
  • Linux web apps
  • Docker containers
  • Mobile apps
  • Functions
App Service environments (ASEs) are appropriate for application workloads that require:
  • Very high scale.
  • Isolation and secure network access.
  • High memory utilization.
Customers can create multiple ASEs within a single Azure region or across multiple Azure regions. This flexibility makes ASEs ideal for horizontally scaling stateless application tiers in support of high RPS workloads.
ASEs are isolated to running only a single customer's applications and are always deployed into a virtual network. Customers have fine-grained control over inbound and outbound application network traffic. Applications can establish high-speed secure connections over VPNs to on-premises corporate resources.
First of all I have to remind where we can find Sitecore ARM templates:



I was digging this topic and I what I got to know more is which ARMs attribute we have to use. The main one are:
  • server farm
  • hosting environment profile
Where we can find them? -> In infrastructure files of Sitecore

I will make here some out off topic, but I recommend to use ARM templates extension for VSCode, check this out:


Take a look on Sitecore ARM infrastructure.json file


But you have to be aware that there is more than 1 place to switch :)

What you can do more is for instance change default Azure App Service Plan usage. Of course not on a production stage, but if you are building only kind of PoC, you don't need all PaaS App Service Plans (which on ASE costs much). You can e.g. create only one for PoC purpose like I said.

What I would like to highlight is that this parameters values we can also pass from the top, what means parameters.json file. In that way we will keep all values in one place.


The same situation is with xCommerce ARMs template, which have similar structure to Sitecore ARMs templates


Because we knowe already, from where we can get default ARMs for Sitecore I will put here only infrastructure files for Sitecore 9.0.2 and xCommerce 9.0.3 to help understand how to use this paramas.
I would like to notice that my custom templatea are only for PoC purposes and I have changed number of App Service Plans. In the other hand, it will be also a good example for you.


Cheers!

Saturday, August 17, 2019

10:42 AM

Azure + Solr support & Sitecore 9.0.2

You could have an situation that you would like to deploy ARMs template with Sitecore 9.0.2 + xCommerce on Azure with custom SOLR search engine. Perfect, so do I ! :)



Fortnately Sitecore provides special ARMs template parameter for SOLR to make it happen and simplify our work.



Let's say that you have already run whole proces of ARMs deployment. After successful Sitecore deployment script will go further to xCommerce part where can facing with some weird SOLR search service Azure message during deployment:

It means that xCommerce doesn't understand this attribute with solr connection string and can't process it. To solve it you have several ways:
  • manually change commerce engine policies and other settings after cloud deployment
  • upgrade only xCommerce part to 9.0.3 version which already work perfect with this parameter as well. 
Please remember that Sitecore stays at version 9.0.2 and doesn't have to be upgraded in any way.

Hope I helped,

Cheers !

Monday, July 15, 2019

4:40 PM

SUGPL - Speaker feelings

Times goes fast and I came on the stage one more time in this year! I love this feeling to be in this place and can share with the knowledge with other guys. This is building pure community, get people, learn together and enjoy at the end during afterparty :)



So my topic of the presentation was "How to PaaS the cloud":


And video version below :)



I tried to help people understand how they should to go with Azure and PaaS approach and which paths they can use to achive needed goals. I hope it will help them :)


Besides that we have also presentations prepared by Patrycjusz Jaskurzynski and Tomasz Juranek who did great job. At the end of course we have celebrated our meetup during afterparty :)

Cheers !

Wednesday, July 10, 2019

7:17 PM

Sitecore & xCommerce: Azure and integrations FAQ

There are situations when your clients use more than only CMS system. Of course now they would like to use Sitecore but with xCommerca part. Is it all? No, they have also some other internal 3rd party systems like own PIM or ERP, CRM or all of them at once.


So now we can start to think how we should to integrate them? Let's check a few approaches which we can chose depends on client needs and our abilities. To make it we will go through a path, sort of journey of questions which you should answer during approaching to your enterprise app to the world.

Hosting

First of all we should think where we would like to keep our solution. Currently, I don't think I should touch things like:
  • internal hosting infrastructure or
  • external providers
Because right now we have cloud age and we will go in Azure! ;)

In Azure as a cloud we also have 2 directions:

          
Each of the path has own specific pros and cons, let's point some of them:

IaaS:
  • DevOps maintanance
  • Flexibility (issue)
  • Complicated solution 
PaaS
  • Simpler maintanance
  • Felxibility (pros)
  • Easy to scale
  • Fancy solution!
When we decide how we will host, then we should to ask ourselves about:

Deploy path

Here we have a two ways:
  • Marketplace
  • ARM templates
Marketplace is well known place to get our Sitecore App, but if we want to make something custom we should ARM templates to define our own rules.

We also should to remember that  ARMs templates:
  
They don’t deploy app code itself, but only define structure of resources

Since we know:
  • Where we will host app
  • How we gonna to deploy on it

We should asks ourselves what about security? This is the most important when you are working with enterprise clients and their solutions. But I'm pretty sure they will not let you forget about that :)

Integration 3rd Party Systems Security and Privacy

  • Azure Gateway

Microsoft describes that the gateway works as a bridge that provides quick data transfer and encryption between data sources on premises and your logic apps. You can use the same gateway installation with other cloud services, such as Power BI, Power Automate, Power Apps, and Azure Analysis Services.
  •  Logic Apps

Combining Azure Logic Apps and Azure OnPrem Gateway gives an ability to process and consume date gathered from on-prem services we have integrated with. You have simple way to
  • Hybrid Connection




To simplify we can get information from documentation which says that Hybrid Connections can be used to access application resources in other networks. It provides access from your app to an application endpoint. It does not enable an alternate capability to access your application. As used in App Service, each Hybrid Connection correlates to a single TCP host and port combination. This means that the Hybrid Connection endpoint can be on any operating system and any application, provided you are accessing a TCP listening port. The Hybrid Connections feature does not know or care what the application protocol is, or what you are accessing. It is simply providing network access.
  • ASE (App Service Environment)


The last one but not least is ASE which represents isolated environemnt inside the Azure Cloud. You can imagin that you have your own hardware resereved only for you in ASE. Basing on that you have wide scope of priviliges to set up you network. You can e.g. hide completly URL to you App services based on that infrastructure. It's really interesing to have so much powers in Azure to use.

Ok basing that let's assume we have choosed ASE, so how could look our infrastructure?

Infrastructure diagram based on Azure ASE approach

For purpose of our excercise let's assume that we would like to integrate with:
  • 2 kinds of ERPs
  • CRM
  • Some Data Warehouse
  • Product managemet system (PIM)

First of all, in this picture we can see that ASE contains WebApps, but not databases. It's because of ASE properties, which allow only to keep App services.

Integration part is delegatd to independent solution which can be maintanance separetly without issues with Sitecore team as well. Besides it provides abiliti to scale it separately as well. Although it also depends on you needs. Because e.g. PIM product synchronization could be an activity which will be invoke once per day (at night for instance), so this is something what we really can extract to independent layer.

However, we can also have a situation where ERP integration will be used 'on the fly' to get e.g. prices per specific customer. Does it mean it's also good to keep in a separate layer?
Well, not excatly. Maybe it's a good idea to this part of integration make in xCommerce area? Then you will can easly assign to xCommerce prices pipline or add and API to make it possible for Sitecore to ask for those data.

We also should mention about Azure Gateway (WAF) which allows to filter traffic to our ASE and set proper network rules. We also have divided here SOLR environment outside, which can be hosted on external VMs for example.

Everythings depens on you needs, but hopefully this diagram will help you to understand approach, constraints and ways how to make it.

Cheers !

Saturday, June 22, 2019

8:27 PM

xCommerce - extend by composition 3/3

So here we are with the next and the last one part of our journey through xCommerce customization path. Now we will take a look on the most proper way to make xCommerce fit to us - composition.



In this way we have to understand how xCommerce solution is build. It has (like Sitecore) own hierarchy flow to process the request. To handle it it uses a few steps:

  • Plugins
  • Controllers and Commands
  • Pipelines
  • Blocks
Let's take a look a bit on them.

 Plugins
  • Independent features
  • Only accepted way to extend Commerce Engine
  • Don’t remove default ones just like that ;)
Controllers & Commands


  • Controllers works in the same way as usuall
  • Commands are invoking inside the controllers
  • Commands invokes Pipelines
 Pipelines


  • You can create your own pipelines and hook into pipelines defined in other plugin
  • Similar to standard Sitecore pipeline mechanism
  • In SXC9 they are in the code not XML
  • Aggregate SXC Blocks
  • Comparing to XML approach No „ShowConfig.ASPX” but JSON preview
  • In Commerce, there is no config patching facilities. Instead we can create our custom plugin and can patch our Blocks through the code.
     
 Blocks



  • Equivalent for Sitecore processors
  • Chaining calls
  • Remember about returning element
Take a look on this examples of adding blocks in a few several ways:



Example

Let's assumme that we have sort of new functionality like subaccounts. To make it work properly we have to add a new controller, command, pipeline and some blocks. To achieve that we have below actions:

  • Controller
  • Command
  • Pipeline
  • Blocks
We also should remember about mentioned earlier registration piplines and blocks in the configuration classes. You will have it also below in the examples of code.
Enjoy!

Saturday, May 25, 2019

12:26 PM

Sitecore Azure ARM PaaS on ASE - Redis

Azure ARM deployment is a very good way to setup our environments in PaaS architecture. Moreover, it allows to customize many things, depends on our project (client) needs.

But sometimes simple things can be complicated, especially when you customizations have some influence on deployment process.

In this post I will share with you with Redis troubleshooting which I did during setuping Sessions on Azure. Especially because of Azure ASE which has an influance on this setup. Some default things don't work out of the box, what can be irritating.


During ARM deployment you can see error like this:



Let's take a look a few potential issues:

We will start with something general (not related to Azure ASE)
  1. Check setting InProc and OutProc of you private and shared sessions in configs (according to docs):
    1. For Private session go to your site root folder, open the web.config file, and locate the sesssionState section:
      <sessionState mode="Inproc" cookieless="false" timeout="20"
    2.  For shared session:
      1.  go to your website root folder, navigate to the App_Config\Sitecore\Marketing.Tracking folder.
      2. Open the Sitecore.Analytics.Tracking.Config file.
      3. Locate the line where you can define the default shared session state provider using the following path: sitecore/tracking/sharedSessionState.
         
  • TIP: Check if the relation between configuration is correct because could be wrong (I had e.g. private session set as out of proc, but shared session was InProc by default). Available combinations let's check here:
  •  
    2. ASE resolving URL
     ASE often can be cut off from external access, what means when Sitecore will try to reach default Redis URL it will not achieve it. Because of that you have to change it to IP in connection string. But...to get Ip of Redis, you have to upgrade it from Standard to Premium level
     

    3. ASE network influence:  
    By default during ARM deployment Sitecore puts every service in default place in your resource group. You have to take care of network and IP ranges which will have it, because being in the same RG doesn't mean it will be in the same network. It may cause to migrate later Redis to different subnet etc.
     4. SSL certificate and ASE
    You can have an issue with connection because of SSL certificate, when it will be self-signed. By default, Sitecore recommend to make it through SSL, but we have to think what in our situation when we use ASE? Well, it's isolated environment and if Redis and CD services communicate in ASE scope SSL is not so important maybe. I leave this decision to you.
     
    I hope it will help for somebody, because I have spent plenty of time on that topic :)
     Cheers!