diff --git a/environment_setup/arm-templates/cloud-environment.json b/environment_setup/arm-templates/cloud-environment.json new file mode 100644 index 00000000..8fd905cb --- /dev/null +++ b/environment_setup/arm-templates/cloud-environment.json @@ -0,0 +1,123 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "baseName": { + "type": "string", + "maxLength": 10, + "minLength": 3, + "metadata": { + "description": "The base name to use as prefix to create all the resources." + } + }, + "location": { + "type": "string", + "defaultValue": "eastus", + "allowedValues": [ + "eastus", + "eastus2", + "southcentralus", + "southeastasia", + "westcentralus", + "westeurope", + "westus2" + ], + "metadata": { + "description": "Specifies the location for all resources." + } + } + }, + "variables": { + "amlWorkspaceName": "[concat(parameters('baseName'),'-AML-WS')]", + "storageAccountName": "[concat(toLower(parameters('baseName')), 'amlsa')]", + "storageAccountType": "Standard_LRS", + "keyVaultName": "[concat(parameters('baseName'),'-AML-KV')]", + "tenantId": "[subscription().tenantId]", + "applicationInsightsName": "[concat(parameters('baseName'),'-AML-AI')]", + "containerRegistryName": "[concat(toLower(parameters('baseName')),'amlcr')]" + }, + "resources": [ + { + "type": "Microsoft.Storage/storageAccounts", + "apiVersion": "2018-07-01", + "name": "[variables('storageAccountName')]", + "location": "[parameters('location')]", + "sku": { + "name": "[variables('storageAccountType')]" + }, + "kind": "StorageV2", + "properties": { + "encryption": { + "services": { + "blob": { + "enabled": true + }, + "file": { + "enabled": true + } + }, + "keySource": "Microsoft.Storage" + }, + "supportsHttpsTrafficOnly": true + } + }, + { + "type": "Microsoft.KeyVault/vaults", + "apiVersion": "2018-02-14", + "name": "[variables('keyVaultName')]", + "location": "[parameters('location')]", + "properties": { + "tenantId": "[variables('tenantId')]", + "sku": { + "name": "standard", + "family": "A" + }, + "accessPolicies": [] + } + }, + { + "type": "Microsoft.Insights/components", + "apiVersion": "2015-05-01", + "name": "[variables('applicationInsightsName')]", + "location": "[if(or(equals(parameters('location'),'eastus2'),equals(parameters('location'),'westcentralus')),'southcentralus',parameters('location'))]", + "kind": "web", + "properties": { + "Application_Type": "web" + } + }, + { + "type": "Microsoft.ContainerRegistry/registries", + "apiVersion": "2017-10-01", + "name": "[variables('containerRegistryName')]", + "location": "[parameters('location')]", + "sku": { + "name": "Standard" + }, + "properties": { + "adminUserEnabled": true + } + }, + { + "type": "Microsoft.MachineLearningServices/workspaces", + "apiVersion": "2018-11-19", + "name": "[variables('amlWorkspaceName')]", + "location": "[parameters('location')]", + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]", + "[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName'))]", + "[resourceId('Microsoft.Insights/components', variables('applicationInsightsName'))]", + "[resourceId('Microsoft.ContainerRegistry/registries', variables('containerRegistryName'))]" + ], + "identity": { + "type": "systemAssigned" + }, + "properties": { + "friendlyName": "[variables('amlWorkspaceName')]", + "keyVault": "[resourceId('Microsoft.KeyVault/vaults',variables('keyVaultName'))]", + "applicationInsights": "[resourceId('Microsoft.Insights/components',variables('applicationInsightsName'))]", + "containerRegistry": "[resourceId('Microsoft.ContainerRegistry/registries',variables('containerRegistryName'))]", + "storageAccount": "[resourceId('Microsoft.Storage/storageAccounts/',variables('storageAccountName'))]" + } + } + ] +} \ No newline at end of file diff --git a/environment_setup/iac-create-environment.yml b/environment_setup/iac-create-environment.yml new file mode 100644 index 00000000..fffaf066 --- /dev/null +++ b/environment_setup/iac-create-environment.yml @@ -0,0 +1,31 @@ +trigger: + branches: + include: + - master + paths: + include: + - environment_setup/arm-templates/* + +pool: + vmImage: 'ubuntu-latest' + +variables: + baseName: $[coalesce(variables['baseNameOverride'], 'mlops')] + location: $[coalesce(variables['locationOverride'], 'centralus')] + azuresub: $[coalesce(variables['azuresubOverride'], 'davete02_sub')] + + +steps: +- task: AzureResourceGroupDeployment@2 + inputs: + azureSubscription: $(azuresub) + action: 'Create Or Update Resource Group' + resourceGroupName: '$(baseName)-AML-RG' + location: $(location) + templateLocation: 'Linked artifact' + csmFile: '$(Build.SourcesDirectory)/environment_setup/arm-templates/cloud-environment.json' + overrideParameters: '-baseName $(baseName)' + deploymentMode: 'Incremental' + displayName: 'Deploy MLOps resources to Azure' + + \ No newline at end of file diff --git a/environment_setup/iac-remove-environment.yml b/environment_setup/iac-remove-environment.yml new file mode 100644 index 00000000..aaf6f060 --- /dev/null +++ b/environment_setup/iac-remove-environment.yml @@ -0,0 +1,27 @@ +trigger: + branches: + include: + - master + paths: + include: + - environment_setup/arm-templates/* + +pool: + vmImage: 'ubuntu-latest' + +variables: + baseName: $[coalesce(variables['baseNameOverride'], 'mlops')] + location: $[coalesce(variables['locationOverride'], 'centralus')] + azuresub: $[coalesce(variables['azuresubOverride'], 'davete02_sub')] + + +steps: +- task: AzureResourceGroupDeployment@2 + inputs: + azureSubscription: $(azuresub) + action: 'DeleteRG' + resourceGroupName: '$(baseName)-AML-RG' + location: $(location) + displayName: 'Delete resources in Azure' + + \ No newline at end of file