Telerik License Key in CI/CD Environment
This article describes how to set up and activate your Telerik UI for Blazor license key across a few popular cloud build and deployment services. You can find guidance and examples on how to set environment variables for some of the most popular CI/CD platforms.
This documentation section applies to Telerik UI for Blazor version 8.0.0 and above. Older versions do not require a license key.
Basics
A Telerik license key is required during application build. During application deployment, this includes all steps that:
- Build the app with
dotnet build - Run unit tests, unless the
dotnet testcommand uses the--no-buildoption - Publish the app, unless the
dotnet publishcommand uses the--no-buildoption
A license key is not required on the web server that hosts the already deployed web application.
The Telerik license activation process in CI/CD test, build, staging, and production environments involves the following steps:
- Go to the License Keys page in your Telerik account and download your license key.
- Set an environment variable with either of the following names:
TELERIK_LICENSE—the value must be the Telerik license key string.TELERIK_LICENSE_PATH—the value must be the full path to the license key file, including the license file name itself.TELERIK_LICENSE_PATHrequiresTelerik.Licensingversion1.4.9and above. You can use it with Telerik UI for Blazor8.1.0and above.
- (optional) Fail the build and deployment if there is an issue with the license key.
In most cases, the recommended way to provide your license key to the Telerik.Licensing NuGet package in CI/CD environments is to use one of the available environment variables.
Treat the license key and the license file as secrets. Always store and retrieve them in a secure manner, according to the build platform's best practices.
Environment Variable Length Limitations
The Telerik license key size depends on the number of licenses it includes, including renewals. Some environments may have a limit on the environment variable size, which is smaller than your Telerik license key length. Such examples include:
- Windows and Windows Server machines (up to 32,767 characters for all environment variables and much smaller limits for setting variables in the Registry or the system settings)
- GitLab (up to 10,000 characters)
In such cases, use TELERIK_LICENSE_PATH or only a license file instead of TELERIK_LICENSE. The TELERIK_LICENSE_PATH variable must point to the Telerik license file location, including the telerik-license.txt file name itself. The license file must be stored and provided to the deployment pipeline in a secure manner.
Azure Pipelines
Azure Pipelines provides built-in tools to store and use secret environment variables and secure files. The recommended option with Classic pipelines is to download the Telerik license file as a secure file.
Use TELERIK_LICENSE
- Create a new secret variable. Also check the separate article Set Secret Variables.
- Paste the contents of the license key file as a value of the secret variable.
- Map the secret variable to a new environment variable named
TELERIK_LICENSE. - Use the
TELERIK_LICENSEenvironment variable in the tasks, steps, or scripts that build and publish the Blazor app. Classic pipelines may need to set an output variable to share and consume the license key in multiple steps.
Using a TELERIK_LICENSE environment variable in Azure Pipeline YAML
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'build'
# ...
env:
TELERIK_LICENSE: $(Secret_Telerik_License_Key)
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
# ...
env:
TELERIK_LICENSE: $(Secret_Telerik_License_Key)
Use TELERIK_LICENSE_PATH
- Add a secure file and grant any necessary permissions to use it in the pipeline.
- Download the secure file in a task with a
name. The secure file path is available to other tasks through thesecureFilePathoutput. - Set the
TELERIK_LICENSE_PATHenvironment variable in all tasks, steps, or scripts that build and publish the Blazor app.
Using a TELERIK_LICENSE_PATH environment variable in Azure Pipeline YAML
steps:
- task: DownloadSecureFile@1
name: telerikLicense
displayName: 'Download telerik-license.txt'
inputs:
secureFile: 'telerik-license.txt'
- task: DotNetCoreCLI@2
inputs:
command: 'build'
# ...
env:
TELERIK_LICENSE_PATH: $(telerikLicense.secureFilePath)
- task: DotNetCoreCLI@2
displayName: 'Publish'
inputs:
command: 'publish'
# ...
env:
TELERIK_LICENSE_PATH: $(telerikLicense.secureFilePath)
GitHub Actions
- Create a new Repository Secret or an Organization Secret.
- Paste the contents of the license key file as a value of the GitHub secret.
- Assign the secret to an environment variable named
TELERIK_LICENSE. - Use the
TELERIK_LICENSEenvironment variable in the steps, which build and publish the Blazor app.
Using a TELERIK_LICENSE environment variable in GitHub Actions
- name: Build Step
run: dotnet build -c Release
env:
TELERIK_NUGET_KEY: ${{ secrets.Telerik_NuGet_Key }}
TELERIK_LICENSE: ${{ secrets.Telerik_License_Key }}
- name: Publish Step
run: dotnet publish -c Release
env:
TELERIK_LICENSE: ${{ secrets.Telerik_License_Key }}
Also see Using API Keys in the article Restoring NuGet Packages in Your CI Workflow. It shows how to use the TELERIK_NUGET_KEY environment variable in your CI build environment.
Docker
- Create a Docker build secret that holds the Telerik license key file.
SH
docker build --secret id=telerik-license-key,src=/path/to/telerik-license.txt . - Mount the secret and set a
TELERIK_LICENSEenvironment variable in the build container. The environment variable is required when building and publishing the Telerik Blazor app.SHRUN --mount=type=secret,id=telerik-license-key,env=TELERIK_LICENSE \ dotnet publish BlazorProjectName.csproj -c Release -o /app/publish /p:UseAppHost=false
Abort Deployment on License Key Error
To avoid accidental license watermarks and notifications on your live site, you can fail the application build and abort deployment when there is an issue with the license key. There are two alternative ways to list the Telerik license warning codes to be treated as errors:
-
Add а
<TelerikLicensingStrict>tag to the.csprojproject file. This approach requires Telerik UI for Blazor version9.0.0and above, orTelerik.Licensingversion1.6.5and above.XML<PropertyGroup> <TargetFramework>net8.0</TargetFramework> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> <TelerikLicensingStrict Condition="$(Configuration) == 'Release'">true</TelerikLicensingStrict> </PropertyGroup> -
Add a
<WarningsAsErrors>tag to the.csprojproject file:XML<PropertyGroup> <TargetFramework>net8.0</TargetFramework> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> <WarningsAsErrors>TKL001;TKL002;TKL003;TKL004;TKL101;TKL102;TKL103;TKL104;TKL105</WarningsAsErrors> </PropertyGroup> -
Set the
-warnaserrorMSBuild switch in thedotnet buildcommand:SHdotnet build -warnaserror:"TKL001;TKL002;TKL003;TKL004;TKL101;TKL102;TKL103;TKL104;TKL105"