Skip to content

Commit

Permalink
Update examples to use decorators (#1685)
Browse files Browse the repository at this point in the history
  • Loading branch information
shenglol authored Mar 2, 2021
1 parent 3e565a5 commit 311f540
Show file tree
Hide file tree
Showing 93 changed files with 7,136 additions and 7,433 deletions.
6 changes: 3 additions & 3 deletions docs/examples/101/1vm-2nics-2subnets-1vnet/main.bicep
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
param virtualMachineSize string
param adminUsername string
param adminPassword string {
secure: true
}

@secure()
param adminPassword string
param storageAccountType string
param location string = resourceGroup().location

Expand Down
15 changes: 7 additions & 8 deletions docs/examples/101/aci-linuxcontainer-public-ip/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ param image string = 'mcr.microsoft.com/azuredocs/aci-helloworld'
param port int = 80
param cpuCores int = 1
param memoryinGb int = 2
param restartPolicy string {
default: 'Always'
allowed: [
'Always'
'Never'
'OnFailure'
]
}

@allowed([
'Always'
'Never'
'OnFailure'
])
param restartPolicy string = 'Always'
param location string = resourceGroup().location

resource containerGroup 'Microsoft.ContainerInstance/containerGroups@2019-12-01' = {
Expand Down
48 changes: 16 additions & 32 deletions docs/examples/101/aks-vmss-systemassigned-identity/main.bicep
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
// params
param dnsPrefix string {
default: 'cl01'
metadata: {
description: 'The DNS prefix to use with hosted Kubernetes API server FQDN.'
}
}
param clusterName string {
default: 'aks101'
metadata: {
description: 'The name of the Managed Cluster resource.'
}
}
param location string {
default: resourceGroup().location
metadata: {
description: 'Specifies the Azure location where the key vault should be created.'
}
}
param agentCount int {
default: 1
minValue: 1
maxValue: 50
metadata: {
description: 'The number of nodes for the cluster. 1 Node is enough for Dev/Test and minimum 3 nodes, is recommended for Production'
}
}
param agentVMSize string {
default: 'Standard_D2_v3'
metadata: {
description: 'The size of the Virtual Machine.'
}
}
@description('The DNS prefix to use with hosted Kubernetes API server FQDN.')
param dnsPrefix string = 'cl01'

@description('The name of the Managed Cluster resource.')
param clusterName string = 'aks101'

@description('Specifies the Azure location where the key vault should be created.')
param location string = resourceGroup().location

@minValue(1)
@maxValue(50)
@description('The number of nodes for the cluster. 1 Node is enough for Dev/Test and minimum 3 nodes, is recommended for Production')
param agentCount int = 1

@description('The size of the Virtual Machine.')
param agentVMSize string = 'Standard_D2_v3'

// vars
var kubernetesVersion = '1.19.0'
Expand Down
272 changes: 136 additions & 136 deletions docs/examples/101/aks-vmss-systemassigned-identity/main.json
Original file line number Diff line number Diff line change
@@ -1,137 +1,137 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"dnsPrefix": {
"type": "string",
"metadata": {
"description": "The DNS prefix to use with hosted Kubernetes API server FQDN."
},
"defaultValue": "cl01"
},
"clusterName": {
"type": "string",
"metadata": {
"description": "The name of the Managed Cluster resource."
},
"defaultValue": "aks101"
},
"location": {
"type": "string",
"metadata": {
"description": "Specifies the Azure location where the key vault should be created."
},
"defaultValue": "[resourceGroup().location]"
},
"agentCount": {
"type": "int",
"minValue": 1,
"maxValue": 50,
"metadata": {
"description": "The number of nodes for the cluster. 1 Node is enough for Dev/Test and minimum 3 nodes, is recommended for Production"
},
"defaultValue": 1
},
"agentVMSize": {
"type": "string",
"metadata": {
"description": "The size of the Virtual Machine."
},
"defaultValue": "Standard_D2_v3"
}
},
"functions": [],
"variables": {
"kubernetesVersion": "1.19.0",
"subnetRef": "[format('{0}/subnets/{1}', resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName')), variables('subnetName'))]",
"addressPrefix": "20.0.0.0/16",
"subnetName": "Subnet01",
"subnetPrefix": "20.0.0.0/24",
"virtualNetworkName": "MyVNET01",
"nodeResourceGroup": "[format('rg-{0}-{1}', parameters('dnsPrefix'), parameters('clusterName'))]",
"tags": {
"environment": "production",
"projectCode": "xyz"
},
"agentPoolName": "agentpool01"
},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-06-01",
"name": "[variables('virtualNetworkName')]",
"location": "[parameters('location')]",
"tags": "[variables('tags')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]"
}
}
]
}
},
{
"type": "Microsoft.ContainerService/managedClusters",
"apiVersion": "2020-09-01",
"name": "[parameters('clusterName')]",
"location": "[parameters('location')]",
"tags": "[variables('tags')]",
"identity": {
"type": "SystemAssigned"
},
"properties": {
"kubernetesVersion": "[variables('kubernetesVersion')]",
"enableRBAC": true,
"dnsPrefix": "[parameters('dnsPrefix')]",
"agentPoolProfiles": [
{
"name": "[variables('agentPoolName')]",
"count": "[parameters('agentCount')]",
"mode": "System",
"vmSize": "[parameters('agentVMSize')]",
"type": "VirtualMachineScaleSets",
"osType": "Linux",
"enableAutoScaling": false,
"vnetSubnetID": "[variables('subnetRef')]"
}
],
"servicePrincipalProfile": {
"clientId": "msi"
},
"nodeResourceGroup": "[variables('nodeResourceGroup')]",
"networkProfile": {
"networkPlugin": "azure",
"loadBalancerSku": "standard"
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"
]
}
],
"outputs": {
"id": {
"type": "string",
"value": "[resourceId('Microsoft.ContainerService/managedClusters', parameters('clusterName'))]"
},
"apiServerAddress": {
"type": "string",
"value": "[reference(resourceId('Microsoft.ContainerService/managedClusters', parameters('clusterName'))).fqdn]"
}
},
"metadata": {
"_generator": {
"name": "bicep",
"version": "dev",
"templateHash": "6792316880994491377"
}
}
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"dnsPrefix": {
"type": "string",
"defaultValue": "cl01",
"metadata": {
"description": "The DNS prefix to use with hosted Kubernetes API server FQDN."
}
},
"clusterName": {
"type": "string",
"defaultValue": "aks101",
"metadata": {
"description": "The name of the Managed Cluster resource."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Specifies the Azure location where the key vault should be created."
}
},
"agentCount": {
"type": "int",
"defaultValue": 1,
"metadata": {
"description": "The number of nodes for the cluster. 1 Node is enough for Dev/Test and minimum 3 nodes, is recommended for Production"
},
"maxValue": 50,
"minValue": 1
},
"agentVMSize": {
"type": "string",
"defaultValue": "Standard_D2_v3",
"metadata": {
"description": "The size of the Virtual Machine."
}
}
},
"functions": [],
"variables": {
"kubernetesVersion": "1.19.0",
"subnetRef": "[format('{0}/subnets/{1}', resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName')), variables('subnetName'))]",
"addressPrefix": "20.0.0.0/16",
"subnetName": "Subnet01",
"subnetPrefix": "20.0.0.0/24",
"virtualNetworkName": "MyVNET01",
"nodeResourceGroup": "[format('rg-{0}-{1}', parameters('dnsPrefix'), parameters('clusterName'))]",
"tags": {
"environment": "production",
"projectCode": "xyz"
},
"agentPoolName": "agentpool01"
},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-06-01",
"name": "[variables('virtualNetworkName')]",
"location": "[parameters('location')]",
"tags": "[variables('tags')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]"
}
}
]
}
},
{
"type": "Microsoft.ContainerService/managedClusters",
"apiVersion": "2020-09-01",
"name": "[parameters('clusterName')]",
"location": "[parameters('location')]",
"tags": "[variables('tags')]",
"identity": {
"type": "SystemAssigned"
},
"properties": {
"kubernetesVersion": "[variables('kubernetesVersion')]",
"enableRBAC": true,
"dnsPrefix": "[parameters('dnsPrefix')]",
"agentPoolProfiles": [
{
"name": "[variables('agentPoolName')]",
"count": "[parameters('agentCount')]",
"mode": "System",
"vmSize": "[parameters('agentVMSize')]",
"type": "VirtualMachineScaleSets",
"osType": "Linux",
"enableAutoScaling": false,
"vnetSubnetID": "[variables('subnetRef')]"
}
],
"servicePrincipalProfile": {
"clientId": "msi"
},
"nodeResourceGroup": "[variables('nodeResourceGroup')]",
"networkProfile": {
"networkPlugin": "azure",
"loadBalancerSku": "standard"
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"
]
}
],
"outputs": {
"id": {
"type": "string",
"value": "[resourceId('Microsoft.ContainerService/managedClusters', parameters('clusterName'))]"
},
"apiServerAddress": {
"type": "string",
"value": "[reference(resourceId('Microsoft.ContainerService/managedClusters', parameters('clusterName'))).fqdn]"
}
},
"metadata": {
"_generator": {
"name": "bicep",
"version": "dev",
"templateHash": "17474268025115212399"
}
}
}
24 changes: 11 additions & 13 deletions docs/examples/101/aks/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@ param dnsPrefix string
param linuxAdminUsername string
param sshRSAPublicKey string
param servicePrincipalClientId string
param servicePrincipalClientSecret string {
secure: true
}

@secure()
param servicePrincipalClientSecret string

// optional params
param clusterName string = 'aks101cluster'
param location string = resourceGroup().location
param osDiskSizeGB int {
default: 0 // a value of zero means they will use the default value (which is 128 as of this writing)
minValue: 0
maxValue: 1023
}

param agentCount int {
default: 3
minValue: 1
maxValue: 50
}
@minValue(0)
@maxValue(1023)
param osDiskSizeGB int = 0

@minValue(1)
@maxValue(50)
param agentCount int = 3

param agentVMSize string = 'Standard_DS2_v2'
// osType was a defaultValue with only one allowedValue, which seems strange?, could be a good TTK test

Expand Down
Loading

0 comments on commit 311f540

Please sign in to comment.