Showing posts with label license. Show all posts
Showing posts with label license. Show all posts

Monday, April 29, 2019

Sitecore Azure Kudu Tools PowerShell Module



I've managed to start several blog post drafts with the intention of sharing a few of my PowerShell scripts - but haven't got around to finishing/posting any of them.

This actually led to an epiphany: the scripts I wanted to share all had an underlying theme: obtaining files using the Kudu Rest API using PowerShell.


Huh? Kudu?

Aw, a baby Kudu!

If you don't already know, Kudu is the "engine behind git deployments" in Azure App Service - but can also be used as a built-in diagnostics tool within Azure.   Any time you have an Azure website, you automatically get a 'companion' Kudu (aka SCM) site accessible via the following URL format:  https://{ResourceName}.scm.azurewebsites.net.  

For example, if your CM App Service name is
'mysitecoresite-xp2-small-prd1-cm',

the corresponding Kudu site would be:
https://mysitecoresite-xp2-small-prd1-cm.scm.azurewebsites.net/ 

If you've ever had to Rebuild the xDB index in Azure Search, Sitecore's documentation walks you through how to do so using the Kudu Debug console.

Kudu REST API

One of my favorite feature of Kudu is the Kudu REST API since any files you can access via FTP are also accessible via the Kudu REST API.   You can download files, upload new ones, etc.

Typically, all you need are:
  1. Subscription ID
  2. Resource Group Name
  3. Resource Name
In Azure Portal - you can copy these values from a resource in the overview panel:


Those values are the key to interact with the API using PowerShell's Invoke-RestMethod.
There are a couple prerequisites:
  1. Azure RM module installed and ConnectAccount has been executed.
  2. Valid Azure credentials (same ones used to log into Azure Portal) to invoke Login-AzureRmAccount (converted to Base64)



Sitecore Azure Kudu Tools

I'd never written a PowerShell Module, but I figured this would be a great segway to learning how. I got to reading -- and tinkering -- and refactoring.  

Before long I had written my first PowerShell Module: Sitecore Azure Kudu Tools.

Sitecore Azure Kudu Tools is a collection of functions (three at the time of this post) built to help you get information/files from Sitecore instances on hosted on Azure PaaS using the Kudu Rest API.

It's available on the PowerShell Gallery or check out the GitHub repository.


Get-SitecoreSupportPackage

Allows you to remotely generate a Sitecore Support Package.  The function will download files defined for Sitecore Support Packages into a specified path, obfuscate sensitive data from ConnectionStrings.config, and compress the contents:

\App_Config\* Global.asax
\Logs\* license.xml
eventlog.xml sitecore.version.xml
Web.config


Why?

While there's a built-in way to obtain Sitecore Support Packages in Sitecore's admin page, being able to remotely obtain this information is a nice alternative.  This is useful not only for providing the required information for Sitecore Support tickets - but also for your own diagnostics.

Usage

Invoke this function using the following syntax:


Output


Alternatively, if you just run Get-SitecoreSupportPackage without any parameters, you'll be prompted to provide each required parameter.



Invoke-SitecoreThumbprintValidation

Provides a way to verify that certificate thumbprints match across Sitecore Azure PaaS Resource Group.  The function will download ConnectionStrings.config and AppSettings.config files from all App Services in a given Resource Group, then display any certificate thumbprints discrepancies.

Why?

If you've ever had to replace thumbprint values across an Azure PaaS Sitecore topology, you know that it can be a bit of a pain identifying all the configs where the old thumbprint needs to be replaced.

Bram Stoop wrote a great post identifying all the places you'll need to modify those thumbprints.  If you're looking to semi-automate this process, you can utilize the Kudu REST API to get all the configurations, then identify any mismatched thumbprint values using PowerShell.

Usage

Invoke this function using the following syntax:


Output




Get-SitecoreFileBackup

Allows you to a full copy of an App Service's website file contents.  This function will download all files from in a given ResourceName.

The following folders are excluded:
_DEV sitecore modules
App_Data sitecore_files
App_Browsers temp
sitecore upload
xsl

Why?

Sometimes I just want everything. If I need to determine discrepancies between environments for any reason, this helps.

Usage

Invoke this function using the following syntax:

Output




What's Next?

Now that the module is established, I've created a few GitHub Issues which I hope to get through quickly.  I also plan to add more functions in the future and am 100% open to contributions. 

Is it perfect? Far from it! It's a work in progress. Thrilled to share anyway.

If you're interested in contributing, please check out the contribute section on the Github repo.

via GIPHY

😊


Thursday, November 15, 2018

Which Version of Sitecore Is This Again?

As someone working with multiple clients spanning various Sitecore versions, I often lose track of which versions of Sitecore I have installed 😑   Sometimes, I want to verify if an issue I've come across is a known issue in that version. Other times, I may be providing information about possible upgrade opportunities.

In any case, there are several approaches to identifying which version of Sitecore a site is using.

The Sitecore Shell

If you have access to the Sitecore shell, head to the Content Editor, click the System Menu button and select License Details.



If your Sitecore version is v 7.5 or lower, you can also find the version on the log in screen (update name not included):



Sitecore.Version.XML

Accessing /sitecore/shell/sitecore.version.xml is one of the easiest and quickest ways to find out version details - and it's always available on the CM server (Sitecore Knowledgebase: How to identify the Sitecore version and installed components)


Again, you're left on your own to find the update name yourself.

Sitecore.Kernel.dll

If you have access to the file system, you can navigate to the /bin folder, find the Sitecore.Kernel.dll and open the file's Properties.  Under the Details tab, the Sitecore Product Version will be visible here.



One caveat to this approach is that starting in Sitecore 8.2 (Initial Release), the product version listed in the Sitecore.Kernel.dll start with version 10.0.0.5597 - making it a little more difficult to quickly identify the Sitecore Product Version:

8 = 10.  Math.

Luckily, this Sitecore Stack Overflow Answer has the mappings you'll need.
Sitecore has provided additional information on their Versioning Policy page regarding their approach to product versioning.

Sitecore PowerShell Extensions

If you have access to the CMS and SPE is installed, running the $PSVersionTable command lists the Sitecore build version. Running $PSVersionTable.BuildVersion will display the Major, Minor, Build, and Revision numbers.  


This information is pulled directly from the Sitecore.Kernel.dll.
Referencing the previously mentioned Sitecore Stack Overflow Answer will give you the product's update name.  




Identifying Local Sitecore Versions with PowerShell

Initially, I wanted to come up with a way to identify every version of Sitecore I have installed on my local machine.  I used PowerShell (naturally)  to write a script that lists all installed Sitecore sites registered in IIS and their respective mapped update name based on an inspection of the Sitecore.Kernel.dll.

Here's the script:


Here's the result:

Listing all my local Sitecore instances with their respective 
With the release of the Sitecore Icon Search Chrome Extension, I was super happy with my experience building a Chrome extension - so I decided to give it another go and build the Sitecore Version Detector Chrome Extension.

That's right. The Sitecore Docs site runs on 7.2 Update-4.  Time for an upgrade? 
The extension is simple - built in pure HTML and Javascript - and checks two things:

Is the site using Sitecore? 

We can determine if a site is built on Sitecore by checking for the response on the site's /layouts/System/VisitorIdentification.aspx URL.  This file has been around since the days of DMS/OMS and is central to Sitecore's tracking mechanism. It's also always accessible from delivery servers!

If it's there, we can assume that the site is using Sitecore.

Which version of Sitecore is being used? 

Using the second method listed at the beginning of this post, the extension requests the current tab's /sitecore/shell/sitecore.version.xml URL for an XML response.  This file, while not always accessible on delivery servers, is often left exposed 💀

If it is accessible, we can parse the Major, Minor, Build and Revision values from the XML, then map to the appropriate update version name.

If a Sitecore version is detected, it will display the full revision (with the update name) and link to its respective http://sdn.sitecore.net or http://doc.sitecore.net version page.

The version's Mainstream Support End Date also displays below the version with a link to the Sitecore Product Lifecycle page 😏

Note: While this may often determine versions for live Sitecore sites (especially older versions of Sitecore), not all environments provide the means to determine the version of Sitecore it runs on as an end-user.  

Enjoy!