Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#175594485] Fix healthcheck gate deploy pipeline #105

Merged
merged 2 commits into from
Nov 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion azure-templates/deploy-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ parameters:
type: string
default: '0.5'

# the resource group must be the same where vnet is created
- name: 'containerInstanceResourceGroup'
type: string
default: 'io-p-rg-common'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we get this value from the environment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

az network vnet subnet list requires resource group to list subnets, so we can't get values from other resources.

I don't think that we'll changes these values often.

  # the resource group must be the same where vnet is created
  - name: 'containerInstanceResourceGroup'
    type: string
    default: 'io-p-rg-common'
  # attached vnet to the container instance
  - name: 'containerInstanceVNet'
    type: string
    default: 'io-p-vnet-common'
  # container instance subnet
  - name: 'containerInstanceSubnet'
    type: string
    default: 'azure-devops'


# attached vnet to the container instance
- name: 'containerInstanceVNet'
type: string
Expand Down Expand Up @@ -135,9 +140,27 @@ steps:
# define a temporary container instance name
CONTAINER_INSTANCE_NAME="${{ parameters.appName }}-deploy"

# check if vnet exists in target resource group (containerInstanceResourceGroup)
OUTPUT_VNET=$(az network vnet list --resource-group '${{ parameters.containerInstanceResourceGroup }}' --query "[?contains(name, '${{ parameters.containerInstanceVNet }}')].name" --output tsv)
if [ "$OUTPUT_VNET" = '${{ parameters.containerInstanceVNet }}' ]; then
echo "VNET '${{ parameters.containerInstanceVNet }}' found, continue"
else
echo "VNET '${{ parameters.containerInstanceVNet }}' not found, fail"
exit 1
fi

# check if subnet exists in target resource group and vnet (containerInstanceResourceGroup, containerInstanceVNet)
OUTPUT_SUBNET=$(az network vnet subnet list --resource-group '${{ parameters.containerInstanceResourceGroup }}' --vnet-name '${{ parameters.containerInstanceVNet }}' --query "[?contains(name, '${{ parameters.containerInstanceSubnet }}')].name" --output tsv)
if [ "$OUTPUT_SUBNET" = '${{ parameters.containerInstanceSubnet }}' ]; then
echo "SUBNET '${{ parameters.containerInstanceSubnet }}' found, continue"
else
echo "SUBNET '${{ parameters.containerInstanceSubnet }}' not found, fail"
exit 1
fi

# create, run container instance in subnet, and get exit code
OUTPUT_CREATE=$(az container create \
--resource-group '${{ parameters.resourceGroupName }}' \
--resource-group '${{ parameters.containerInstanceResourceGroup }}' \
--name ${CONTAINER_INSTANCE_NAME} \
--image microsoft/azure-cli:latest \
--cpu '${{ parameters.containerInstanceCpu }}' \
Expand Down