How to use Replace Tokens in Azure Pipelines

// For development:
https://dev-other-service/api/
// For production:
https://prd-other-service/api/
  • 1- The configuration to use .NET 6 will be added
  • 2- The application will be build
  • 3- The application will be zipped and published to the pipeline artifacts
  • 1- The files will be extracted to a folder
  • 2- The replace tokens task will replace the tokens
  • 3- The old files will be deleted
  • 3- The new files (with the new values in the tokens) will be zipped
  • 4- The new files will be deployed with the new values in the tokens
  • 5- The application will be deployed to an App Service
  • In this stage, we have the same tasks as the Development stage and the acceptance stage, the only difference is that the tokens will be replaced with the values configured in the production group variables (from Pipelines Library)
  • First, we extract the files into a folder;
  • Second, we configure the root directory to the same location that the files were extracted in the previous task, and configure which files we want to replace the tokens, in this example, are the JSON files that starts with “appsettings”;
  • Third, we delete the old files;
  • Fourth, we archive the new files to be deployed;
  • Fifth, we deploy the app;
  • 1- Node.js will be installed
  • 2- The application will be build
  • 3- The files will be zipped
  • 4- The artifact will be created
  • 1- The files will be extracted to a folder
  • 2- The replace tokens task will replace the tokens
  • 3- The files will be zipped
  • 4- The files will be deployed with the new values in the tokens
  • In this stage, we have the same tasks as the Development stage, the only difference is that the tokens will be replaced with the values configured in the production group variables (from Pipelines Library)
  • First, we extract the files into a folder;
  • Second, we configure the root directory to the same location that the files were extracted in the previous task, and configure which files we want to replace the tokens, in this example, are the JavaScripts files that starts with “main”;
  • Third, we archive the new files to be deployed;
  • Fourth, we deploy the app;
https://github.com/henriquesd/ReplaceTokensExamples

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Henrique Siebert Domareski

Henrique Siebert Domareski

I've been working with software development with .NET since 2011, and love programming and solve problems using clean code particles.