Telerik License Key in CI/CD Environment
This article describes how to set up and activate your Telerik UI for Blazor License across a few popular cloud build and deployment services. Use Deployment Keys for build pipelines and provide the key through an environment variable or a secure file.
Deployment keys are a dedicated type of license key for build pipelines. They’re tied to a specific application and the set of products that the application uses. Deployment keys cannot be used on personal computers for application development.
Developer license keys remain valid for CI/CD deployments, so existing pipelines do not need to be updated. For new pipelines, we recommend using deployment keys. For more information, see the differences between developer license keys and deployment keys.
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 deployment 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 deployment key is not required on the web server that hosts the already deployed web application.
To activate your license in a CI/CD environment:
- Navigate to the Deployment Keys page.
- Click
Add Application. In the form that opens:
a. Add the application name.
b. Select the type of application—public or private.
c. Select the set of products used in the application.
3. Copy the key value and store it securely.
4. Create an environment variable named TELERIK_LICENSE and set it to the obtained key value. Alternatively, the key can be stored in a telerik-license.txt file, for example when using the Azure Secure files approach.
Creating an Environment Variable
The recommended approach for providing your license key to the Telerik.Licensing NuGet package is to use environment variables. Each CI/CD platform has a different process for setting environment variables and this article lists only some of the most popular examples.
The Telerik Licensing environment variables are:
TELERIK_LICENSE—the value must be the Telerik deployment 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.
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)
Deployment keys are shorter than developer license keys. Using deployment keys for CI/CD pipelines is recommended and helps avoid environment-variable limits.
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 deployment key 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.
In the following example, replace Secret_Telerik_License_Key with the actual pipeline variable name.
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 deployment key 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"