Azure Cloud - studiofu/brain GitHub Wiki
Pipeline
The execution steps
Stages > Jobs > Steps > Tasks
You can define many tasks to archive your objective, such as copy file, deploy to app container
trigger:
- master
pool:
vmImage: ubuntu-latest
stages:
- stage: Build
jobs:
- job: prebuild
steps:
- script: echo Building!
- job: build
steps:
- script: echo "hello world !"
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'package'
- bash: ls -R $(System.DefaultWorkingDirectory)
- task: CopyFiles@2
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)'
Contents: '**'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- bash: ls -R $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
- stage: Test
jobs:
- job: TestOnWindows
steps:
- script: echo Testing on Windows!
- job: TestOnLinux
steps:
- script: echo Testing on Linux!
- stage: Deploy
jobs:
- job: Deploy
steps:
- script: echo Deploying the code!
- bash: echo $(MyName)
Pipeline Approval
Define in the environment and add the approver, for example, in the qa environment, add the approver and need to be approved before going into the stage of DevDeploy
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: Build
jobs:
- job: BuildJob
steps:
- bash: echo "Do the build"
- stage: DevDeploy
jobs:
- deployment: DevDeployJob
environment: Dev
strategy:
runOnce:
deploy:
steps:
- script: echo deploy to Dev
- stage: QADeploy
jobs:
- deployment: QADeployJob
environment: QA
strategy:
runOnce:
deploy:
steps:
- script: echo deploy to QA
Deploy to Docker Hub Registry
need to define the service connection in Azure Pipeline Project for connecting to the docker hub
trigger:
- master
resources:
- repo: self
variables:
tag: '$(Build.BuildId)'
stages:
- stage: Build
displayName: Build image
jobs:
- job: Build
displayName: Build
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Docker@2
inputs:
containerRegistry: 'Docker-Hub'
repository: 'foosi/demo-react-app'
command: 'buildAndPush'
Dockerfile: '**/Dockerfile'
tags: '$(tag)'
Build Docker Image and Deploy to Kubernetes Cluster
rigger:
- master
resources:
- repo: self
variables:
tag: '$(Build.BuildId)'
stages:
# Stage 1
# Build Docker Image
# Publish the K8S Files
- stage: Build
displayName: Build image
jobs:
- job: Build
displayName: Build
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Docker@2
inputs:
containerRegistry: 'in28min-docker-hub'
repository: 'in28min/currency-exchange-devops'
command: 'buildAndPush'
Dockerfile: '**/Dockerfile'
tags: '$(tag)'
- task: CopyFiles@2
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)'
Contents: '**/*.yaml'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'manifests'
publishLocation: 'Container'
# Stage 2
# Download the K8S Files
# Deploy to K8S Cluster with Docker Image
- stage: Deploy
displayName: Deploy image
jobs:
- job: Deploy
displayName: Deploy
pool:
vmImage: 'ubuntu-latest'
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'manifests'
itemPattern: '**/*.yaml'
targetPath: '$(System.ArtifactsDirectory)'
- task: KubernetesManifest@0
inputs:
action: 'deploy'
kubernetesServiceConnection: 'azure-kubernetes-connection'
namespace: 'default'
manifests: '$(System.ArtifactsDirectory)/configuration/kubernetes/deployment.yaml'
containers: 'in28min/currency-exchange-devops:$(tag)'
APIM
In APIM, to define Product and APIs
one for external
one for internal
and each Product/APIs contain many operations.
Regarding to eSmart, for the internal API call, it is required to group all the modules APIs into one Product which only allowed for internal call.
For external Call, AADBC and Open ID should be required.
Resources
Site to Site Connection
Express Route Circuit
https://docs.microsoft.com/en-us/azure/expressroute/expressroute-circuit-peerings
API Management with virtual network
https://docs.microsoft.com/en-us/azure/api-management/api-management-using-with-vnet
Azure API Management by using Azure Automation
https://docs.microsoft.com/en-us/azure/api-management/automation-manage-api-management
Azure API Management deployed to Internal Virtual Network
https://docs.microsoft.com/en-us/azure/api-management/api-management-using-with-internal-vnet
Azure Point to Site VPN
https://dotblogs.com.tw/jamesfu/2015/05/25/pointtosite
Create a Site to Site connection in Azure portal