In order to successfully deploy the token service, you will need to have deployed the following resources.
- Azure Container Registry
- Azure Kubernetes Service
- Azure Key Vault
- Azure Cosmos DB Account
- Docker application needs to be in running
If these are not available, please follow the resource deployment steps.
-
Run PowerShell 7.1
-
Run Change Directory command to Navigate to the Path where deployapplications.ps1 is present
PS C:\Users\>cd <driectory path>
-
Run the .\deployapplications.ps1
Powershell.exe -executionpolicy remotesigned -File .\deployapplications.ps1
-
Accept the log-in request through your browser
-
Enter the following detail in console when prompted which are obtained from previous script(resourcedeployment.ps1) output
SubscriptionId : The Subscription ID for where you want to manage your resources ResourcegroupName : Resource group name where the resources are deployed ContainerRegistryName : Container registry name where the docker image will be uploaded kubernetesName : Kubernetes cluster name
-
After the successful execution of script, the Token service will be deployed.
Note: This script will also update appsettings.json for the sample console service with values required to communicate with this service.
You've successfully deployed the Token service!
Next, please go to Solution Testing.
-
Log in to the Azure portal
az login
-
Set the Azure account Subscription ID
az account set --subscription mysubscriptionid
-
Setup Azure Container Registry
az acr update --name mycontainerregistryname --admin-enabled true
-
Retrieving Configuration Setting in Container Registry
$acrList = az acr list | Where-Object { $_ -match $containerRegistryName + ".*" } $loginServer = $acrList[1].Split(":")[1].Replace('"', '').Replace(',', '').Replace(' ', '') $registryName = $acrList[2].Split(":")[1].Replace('"', '').Replace(',', '').Replace(' ', '') $userName = $registryName $password = ( az acr credential show --name $userName | ConvertFrom-Json).passwords.value.Split(" ")[1]
-
Setup Azure Kubernetes Service and Azure Container Service
az aks update -n mykubernetesservicename -g myresourcegroupname --attach-acr mycontainerregistryname
-
Build the Container and push the Azure Container Registry
Set-location <Replace Source code path> docker build -f <Replace docker file path> --rm -t <Define token service name for container registry>. docker tag <Replace token service name for container registry> <mycontainerregistryname.azurecr.io + token service name defined above> docker login <mycontainerregistryname.azurecr.io > -u $userName -p $password docker push "$mycontainerregistryname.azurecr.io/tokenservicehub/acrtokenservice" Set-Location ..
-
Set up Azure Kubernetes Service and Deploy Applications from Azure Container Registry
az aks get-credentials -g myresourceGroupName -n mykubernetesName
-
Set up Deployment yaml file to deploy APIs
((Get-Content -path manifests\kubernetes-deployment.yaml.template -Raw) -replace '{acrname}', mycontainerregistryname) | Set-Content -Path manifests\kubernetes-deployment.yaml
-
Deploy Services from Azure Container Registry to Kubernetes, and create namespace
kubectl create ns tokenservicehub
-
Deploy Containers to Kubernetes
kubectl apply -f manifests\kubernetes-deployment.yaml --namespace tokenservicehub