Tailwind Traders 后端服务
This repository contains all code + deployment scripts for the Tailwind Traders Backend.
For this demo reference, we built several consumer and line-of-business applications and a set of backend services. You can find all repositories in the following locations:
Tailwind Traders supports two deployment scenarios:
A Service Principal is needed for creating the AKS. If you use the CLI for create the resources, you can reuse a SP one passing to the script the id and password as optional parameters; if not, the script will create a new one for you and will print the details (id and password among them).
In case you use Azure Portal for the resources' creation, you can also reuse a SP or create manually a new one for passing the credentials to the template.
If you want to create a Service Principal, you can do so via the CLI
az ad sp create-for-rbac --skip-assignment --name myAKSClusterServicePrincipalThe output is similar to the following example. Make a note of your own appId and password. These values are used when you create an AKS cluster throughout this guide.
{
"appId": "559513bd-0c19-4c1a-87cd-851a26afd5fc",
"displayName": "myAKSClusterServicePrincipal",
"name": "http://myAKSClusterServicePrincipal",
"password": "e763725a-5eee-40e8-a466-dc88d980f415",
"tenant": "72f988bf-86f1-41af-91ab-2d7cd011db48"
}You can deploy all basics scenarios using one script under /Deploy folder.
Deploy Tailwind Traders Backend on Azure AKS and Azure resources (CosmosDb and Storage accounts)
Running the following command you can deploy starting with the infrastructure and ending with deploying the images on the storage:
.\Deploy-Unified.ps1 -resourceGroup -location -clientId -password -subscription resourceGroup: The name of your resource group where all infrastructure will be created Requiredlocation: Select where you want to create your resource group, for example: eastus RequiredclientId: Id of the service principal used to create the AKS Required if your user does not have permissions to create a new onepassword: Password of the service principal Requiredsubscription: Id of your subscription where you are going to deploy your resource group RequiredThe process will take few minutes.
Deploy Tailwind Traders Backend on Windows and Linux containers in AKS
Running the following command you can deploy starting with the infrastructure and ending with deploying the images on the storage. This command requires more parameters than Linux scenario because we need to build and deploy a WCF service.
Note For mixed (Windows and Linux containers) scenario we need to deploy Tailwind Traders Rewards before it. Because you are going to need some resources that Tailwind Traders Rewards creates.
.\Deploy-Unified-WinLinux.ps1 -resourceGroup -location -clientId -password -subscription -deployWinLinux $true -rewardsResourceGroup -rewardsDbPassword deployWinLinux: Flag needed to execute Windows-Linux scenariocsprojPath: Path location where Tailwind.Traders.Rewards.Registration.Api.csproj is in your machine RequiredmsBuildPath: Path location where MSBuild.exe is, for example: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\BinrewardsResourceGroup: The name of the resource group where Tailwind Traders Rewards is deployed RequiredrewardsDbPassword: Tailwind Traders Rewards database password (Tailwind Traders Rewards Registration, WCF service, connects to this database) RequiredThe process will take few minutes, more than Linux scenario, it will create an Azure Kubernetes Service with Windows and Linux nodes.
In addition to the following documentation you can also deploy infrastructure and services step by step.
To run Tailwind Traders you need to create the Azure infrastructure. There are two ways to do it. Using Azure portal or using a Powershell script.
An ARM script is provided so you can automate the creation of the resources required for the backend services just clicking following button:
Azure portal will ask you for the following parameters:
servicePrincipalId: Id of the service principal used to create the AKSservicePrincipalSecret: Password of the service principalaksVersion: AKS version to use (at least 1.14).The deployment could take more than 10 minutes, and once finished all needed resources will be created:
You can use the CLI to deploy the ARM script. Open a Powershell window from the /Deploy/powershell folder and run the Deploy-Arm-Azure.ps1 with following parameters:
-resourceGroup: Name of the resource group-location: Location of the resource groupYou can optionally pass two additional parameters:
-clientId: Id of the service principal uesd to create the AKS-password: Password of the service principalIf these two parameters are not passed a new service principal will be created.
There is an additional optional parameters to control some aspects of what is created:
-deployAks: If set to $false AKS and ACR are not created. This is useful if you want to create the AKS yourself or use an existing AKS. Defaults to $true. If this parameter is $true the resource group can't exist (AKS must be deployed in a new resource group).Once script finishes, everything is installed. If a service principal has been created, the script will output the service principal details - please, take note of the appId and password properties for use them in the AKS deployment
Pre-requisites for this deployment are to have:
From the terminal type:
az login and follow instructions to log into your Azure.az account list -o table to list all your Azure subscriptions. Then type az account set --subscription to select your subscriptionaz aks get-credentials -n -g to download the configuration files that kubectl needs to connect to your AKS.At this point if you type kubectl config current-context the name of your AKS cluster should be displayed. That means that kubectl is ready to use your AKS
Before deploying services using Helm, you need to setup the configuration. We refer to the configuration file with the name of gvalues file. This file contains all secrets and connection strings so beware to not commit in your repo accidentally.
An example of this file is in helm/gvalues.yaml. The deployment scripts use this file by default, but do not rely on editing this file. Instead create a copy of it a folder outside the repository and use the -valuesFile parameter of the deployment script.
Note: The folder
/Deploy/helm/__values/is added to.gitignore, so you can keep all your configuration files in it, to avoid accidental pushes.
Note: If you come from the Windows and Linux containers scenario you must add the Rewards database's connection string, in the values file you are using, for example:
inf:
(...)
db:
(...)
rewards:
host: tcp:*****.database.windows.net
port: "1433"
catalog: rewardsdb # you must not modify this name
user: ttuser
pwd: YourPassword
(...)Please refer to the comments of the file for its usage. Just ignore (but not delete) the tls section (it is used if TLS is enabled).
Generating a valid gvalues file can be a bit harder, so there is a Powershell script that can do all work by you. This script assumes that all resources are deployed in the same resource group, and this resource group contains only the Tailwind Traders resources. Also assumes the Azure resources have been created using the tools provided in this repo.
Note The Generate-Config.ps1 uses the application-insights CLI extension to find the application insights id. Install it with
az extension add --name application-insights
To auto-generate your gvalues file just go to /Deploy/powershell folder and from a Powershell window, type the following:
.\Generate-Config.ps1 -resourceGroup -outputFile ..\helm\__values\The parameters that Generate-Config.ps1 accepts are:
-resourceGroup: Resource group where all Azure resources are. Required.-outputFile: Full path of the output file to generate. A good idea is to generate a file in /Deploy/helm/__values/ folder as this folder is ignored by Git. If not passed the result file is written on screen.-gvaluesTemplate: Template of the gvalues file to use. The parameter defaults to the /Deploy/helm/gvalues.template which is the only template provided.The script checks that all needed resources exists in the resource group. If some resource is missing or there is an unexpected resource, the script exits.
If you come from the Windows and Linux containers in AKS scenario and you want to use the rewards registration service you have to pass also the following parameters:
-rewardsResourceGroup: Fill it if you are going to use Rewards DB (this is used, for example in the Windows and Linux containers in AKS scenarios).-rewardsDbPassword: The database password for the administrator user. Required if a rewardsResourceGroup is provided.Otherwise the script will disable the rewards registration service.
Docker images are stored in a ACR (a private Docker Registry hosted in Azure).
Before deploying anything on AKS, a secret must be installed to allow AKS to connect to the ACR through a
暂无开放 Issues,或尚未同步最近议题。