diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 3729ff0..0000000 --- a/.dockerignore +++ /dev/null @@ -1,25 +0,0 @@ -**/.classpath -**/.dockerignore -**/.env -**/.git -**/.gitignore -**/.project -**/.settings -**/.toolstarget -**/.vs -**/.vscode -**/*.*proj.user -**/*.dbmdl -**/*.jfm -**/azds.yaml -**/bin -**/charts -**/docker-compose* -**/Dockerfile* -**/node_modules -**/npm-debug.log -**/obj -**/secrets.dev.yaml -**/values.dev.yaml -LICENSE -README.md \ No newline at end of file diff --git a/arm/azureAcaDeploy.json b/arm/azureAcaDeploy.json deleted file mode 100644 index 68c09a2..0000000 --- a/arm/azureAcaDeploy.json +++ /dev/null @@ -1,917 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.17.1.54307", - "templateHash": "5692427675602515188" - } - }, - "parameters": { - "location": { - "type": "string", - "defaultValue": "eastus", - "allowedValues": [ - "southcentralus", - "eastus", - "westeurope" - ], - "metadata": { - "description": "Location where all resources will be deployed. This value defaults to the **East US** region." - } - }, - "name": { - "type": "string", - "defaultValue": "[concat('h',uniqueString(resourceGroup().id) )]", - "maxLength": 15, - "metadata": { - "description": "Unique name for the deployed services below. Max length 15 characters, alphanumeric only:\r\n- Azure Cosmos DB for NoSQL\r\n- Azure Cosmos DB for MongoDB vCore\r\n- Azure OpenAI\r\n- Azure App Service\r\n- Azure Functions\r\n\r\nThe name defaults to a unique string generated from the resource group identifier.\r\n" - } - }, - "openAiEndpoint": { - "type": "string", - "metadata": { - "description": "The OpenAI Endpoint" - } - }, - "openAiKey": { - "type": "string", - "metadata": { - "description": "The OpenAI API key" - } - }, - "openAiCompletionsDeployment": { - "type": "string", - "metadata": { - "description": "The OpenAI Completions Deployment" - } - }, - "openAiEmbeddingsDeployment": { - "type": "string", - "metadata": { - "description": "The OpenAI Embeddings Deployment" - } - } - }, - "variables": { - "cosmosDbSettings": { - "name": "[format('{0}-cosmos-nosql', parameters('name'))]", - "databaseName": "database" - }, - "cognitiveSearchSettings": { - "name": "[format('{0}-cog-search', parameters('name'))]", - "sku": "basic" - }, - "openAiSettings": { - "name": "[format('{0}-openai', parameters('name'))]", - "sku": "S0", - "deployments": { - "completions": { - "sku": { - "name": "Standard", - "capacity": 120 - }, - "model": { - "name": "gpt-35-turbo", - "version": "0301" - } - }, - "embeddings": { - "sku": { - "name": "Standard", - "capacity": 120 - }, - "model": { - "name": "text-embedding-ada-002", - "version": "2" - } - } - } - }, - "cosmosContainers": { - "embeddingContainer": { - "name": "embedding", - "partitionKeyPath": "/id", - "maxThroughput": 1000 - }, - "completionsContainer": { - "name": "completions", - "partitionKeyPath": "/sessionId", - "maxThroughput": 1000 - }, - "productContainer": { - "name": "product", - "partitionKeyPath": "/categoryId", - "maxThroughput": 1000 - }, - "customerContainer": { - "name": "customer", - "partitionKeyPath": "/customerId", - "maxThroughput": 1000 - }, - "leasesContainer": { - "name": "leases", - "partitionKeyPath": "/id", - "maxThroughput": 1000 - } - }, - "vnetSettings": { - "name": "[format('{0}-vnet', parameters('name'))]", - "addressPrefix": "10.244.0.0/16", - "subnets": { - "aks-subnet": { - "addressPrefix": "10.244.0.0/16" - } - } - }, - "acrSettings": { - "name": "[format('{0}cr', parameters('name'))]", - "sku": "Standard", - "tier": "Standard" - }, - "laSettings": { - "name": "[format('{0}-la', parameters('name'))]" - }, - "aiSettings": { - "name": "[format('{0}-ai', parameters('name'))]" - } - }, - "resources": [ - { - "type": "Microsoft.DocumentDB/databaseAccounts", - "apiVersion": "2022-08-15", - "name": "[variables('cosmosDbSettings').name]", - "location": "[parameters('location')]", - "kind": "GlobalDocumentDB", - "properties": { - "consistencyPolicy": { - "defaultConsistencyLevel": "Session" - }, - "databaseAccountOfferType": "Standard", - "locations": [ - { - "failoverPriority": 0, - "isZoneRedundant": false, - "locationName": "[parameters('location')]" - } - ] - } - }, - { - "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases", - "apiVersion": "2022-08-15", - "name": "[format('{0}/{1}', variables('cosmosDbSettings').name, variables('cosmosDbSettings').databaseName)]", - "properties": { - "resource": { - "id": "[variables('cosmosDbSettings').databaseName]" - } - }, - "dependsOn": [ - "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbSettings').name)]" - ] - }, - { - "copy": { - "name": "cosmosContainer", - "count": "[length(items(variables('cosmosContainers')))]" - }, - "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers", - "apiVersion": "2022-08-15", - "name": "[format('{0}/{1}/{2}', variables('cosmosDbSettings').name, variables('cosmosDbSettings').databaseName, items(variables('cosmosContainers'))[copyIndex()].value.name)]", - "properties": { - "resource": { - "id": "[items(variables('cosmosContainers'))[copyIndex()].value.name]", - "partitionKey": { - "paths": [ - "[items(variables('cosmosContainers'))[copyIndex()].value.partitionKeyPath]" - ], - "kind": "Hash", - "version": 2 - } - }, - "options": { - "autoscaleSettings": { - "maxThroughput": "[items(variables('cosmosContainers'))[copyIndex()].value.maxThroughput]" - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', variables('cosmosDbSettings').name, variables('cosmosDbSettings').databaseName)]" - ] - }, - // { - // "type": "Microsoft.CognitiveServices/accounts", - // "apiVersion": "2023-05-01", - // "name": "[variables('openAiSettings').name]", - // "location": "EastUS", - // "sku": { - // "name": "[variables('openAiSettings').sku]" - // }, - // "kind": "OpenAI", - // "properties": { - // "customSubDomainName": "[variables('openAiSettings').name]", - // "publicNetworkAccess": "Enabled" - // } - // }, - // { - // "type": "Microsoft.CognitiveServices/accounts/deployments", - // "apiVersion": "2023-05-01", - // "name": "[concat(variables('openAiSettings').name, '/completions')]", - // "dependsOn": [ - // "[resourceId('Microsoft.CognitiveServices/accounts', variables('openAiSettings').name)]" - // ], - // "sku": { - // "name": "[variables('openAiSettings').deployments.completions.sku.name]", - // "capacity": "[variables('openAiSettings').deployments.completions.sku.capacity]" - // }, - // "properties": { - // "model": { - // "format": "OpenAI", - // "name": "[variables('openAiSettings').deployments.completions.model.name]", - // "version": "[variables('openAiSettings').deployments.completions.model.version]" - // }, - // "versionUpgradeOption": "OnceNewDefaultVersionAvailable" - // } - // }, - // { - // "type": "Microsoft.CognitiveServices/accounts/deployments", - // "apiVersion": "2023-05-01", - // "name": "[concat(variables('openAiSettings').name, '/embeddings')]", - // "dependsOn": [ - // "[resourceId('Microsoft.CognitiveServices/accounts', variables('openAiSettings').name)]", - // "[concat(resourceId('Microsoft.CognitiveServices/accounts', variables('openAiSettings').name), '/deployments/completions')]" - // ], - // "sku": { - // "name": "[variables('openAiSettings').deployments.embeddings.sku.name]", - // "capacity": "[variables('openAiSettings').deployments.embeddings.sku.capacity]" - // }, - // "properties": { - // "model": { - // "format": "OpenAI", - // "name": "[variables('openAiSettings').deployments.embeddings.model.name]", - // "version": "[variables('openAiSettings').deployments.embeddings.model.version]" - // }, - // "versionUpgradeOption": "OnceNewDefaultVersionAvailable" - // } - // }, - { - "type": "Microsoft.Search/searchServices", - "apiVersion": "2022-09-01", - "name": "[variables('cognitiveSearchSettings').name]", - "location": "[parameters('location')]", - "sku": { - "name": "[variables('cognitiveSearchSettings').sku]" - }, - "properties": { - "replicaCount": 1, - "partitionCount": 1, - "hostingMode": "default", - "publicNetworkAccess": "Enabled", - "networkRuleSet": { - "ipRules": [] - }, - "encryptionWithCmk": { - "enforcement": "Unspecified" - }, - "disableLocalAuth": false, - "authOptions": { - "apiKeyOnly": {} - } - } - }, - { - "type": "Microsoft.ContainerRegistry/registries", - "apiVersion": "2023-01-01-preview", - "name": "[variables('acrSettings').name]", - "location": "[parameters('location')]", - "sku": { - "name": "[variables('acrSettings').sku]", - "tier": "[variables('acrSettings').tier]" - }, - "properties": { - "adminUserEnabled": true, - "policies": { - "quarantinePolicy": { - "status": "disabled" - }, - "trustPolicy": { - "type": "Notary", - "status": "disabled" - }, - "retentionPolicy": { - "days": 7, - "status": "disabled" - }, - "exportPolicy": { - "status": "enabled" - }, - "azureADAuthenticationAsArmPolicy": { - "status": "enabled" - }, - "softDeletePolicy": { - "retentionDays": 7, - "status": "disabled" - } - }, - "encryption": { - "status": "disabled" - }, - "dataEndpointEnabled": false, - "publicNetworkAccess": "Enabled", - "networkRuleBypassOptions": "AzureServices", - "zoneRedundancy": "Disabled", - "anonymousPullEnabled": true - } - }, - { - "type": "Microsoft.ContainerRegistry/registries/scopeMaps", - "apiVersion": "2023-01-01-preview", - "name": "[concat(variables('acrSettings').name, '/_repositories_admin')]", - "dependsOn": [ - "[resourceId('Microsoft.ContainerRegistry/registries', variables('acrSettings').name)]" - ], - "properties": { - "description": "Can perform all read, write and delete operations on the registry", - "actions": [ - "repositories/*/metadata/read", - "repositories/*/metadata/write", - "repositories/*/content/read", - "repositories/*/content/write", - "repositories/*/content/delete" - ] - } - }, - { - "type": "Microsoft.ContainerRegistry/registries/scopeMaps", - "apiVersion": "2023-01-01-preview", - "name": "[concat(variables('acrSettings').name, '/_repositories_pull')]", - "dependsOn": [ - "[resourceId('Microsoft.ContainerRegistry/registries', variables('acrSettings').name)]" - ], - "properties": { - "description": "Can pull any repository of the registry", - "actions": [ - "repositories/*/content/read" - ] - } - }, - { - "type": "Microsoft.ContainerRegistry/registries/scopeMaps", - "apiVersion": "2023-01-01-preview", - "name": "[concat(variables('acrSettings').name, '/_repositories_push')]", - "dependsOn": [ - "[resourceId('Microsoft.ContainerRegistry/registries', variables('acrSettings').name)]" - ], - "properties": { - "description": "Can push to any repository of the registry", - "actions": [ - "repositories/*/content/read", - "repositories/*/content/write" - ] - } - }, - { - "type": "Microsoft.OperationalInsights/workspaces", - "apiVersion": "2021-12-01-preview", - "name": "[variables('laSettings').name]", - "location": "eastus", - "properties": { - "sku": { - "name": "Standalone" - }, - "retentionInDays": 31, - "features": { - "enableLogAccessUsingOnlyResourcePermissions": true - }, - "workspaceCapping": { - "dailyQuotaGb": -1 - }, - "publicNetworkAccessForIngestion": "Enabled", - "publicNetworkAccessForQuery": "Enabled" - } - }, - { - "type": "Microsoft.Insights/components", - "apiVersion": "2020-02-02", - "name": "[variables('aiSettings').name]", - "location": "[parameters('location')]", - "kind": "web", - "properties": { - "Application_Type": "web", - "Flow_Type": "Bluefield", - "Request_Source": "rest", - "RetentionInDays": 30, - "WorkspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces', variables('laSettings').name)]", - "IngestionMode": "LogAnalytics", - "publicNetworkAccessForIngestion": "Enabled", - "publicNetworkAccessForQuery": "Enabled" - }, - "dependsOn": [ - "[resourceId('Microsoft.OperationalInsights/workspaces', variables('laSettings').name)]" - ] - }, - { - "type": "Microsoft.Storage/storageAccounts", - "apiVersion": "2021-09-01", - "name": "[format('{0}promptsa', parameters('name'))]", - "location": "[parameters('location')]", - "kind": "Storage", - "sku": { - "name": "Standard_LRS" - } - }, - { - "type": "Microsoft.Network/virtualNetworks", - "apiVersion": "2022-09-01", - "name": "[variables('vnetSettings').name]", - "location": "[parameters('location')]", - "properties": { - "addressSpace": { - "addressPrefixes": [ - "[variables('vnetSettings').addressPrefix]" - ] - }, - "subnets": [ - { - "name": "aks-subnet", - "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetSettings').name, 'aks-subnet')]", - "properties": { - "addressPrefix": "[variables('vnetSettings').subnets['aks-subnet'].addressPrefix]", - "delegations": [ - { - "name": "Microsoft.App.environments", - "id": "[concat(resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetSettings').name, 'aks-subnet'), '/delegations/Microsoft.App.environments')]", - "properties": { - "serviceName": "Microsoft.App/environments" - }, - "type": "Microsoft.Network/virtualNetworks/subnets/delegations" - } - ], - "privateEndpointNetworkPolicies": "Disabled", - "privateLinkServiceNetworkPolicies": "Enabled" - }, - "type": "Microsoft.Network/virtualNetworks/subnets" - } - ], - "virtualNetworkPeerings": [], - "enableDdosProtection": false - } - }, - { - "type": "Microsoft.Network/virtualNetworks/subnets", - "apiVersion": "2022-09-01", - "name": "[concat(variables('vnetSettings').name, '/aks-subnet')]", - "dependsOn": [ - "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetSettings').name)]", - "[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('vnetSettings').name, '-aks-subnet-nsg'))]" - ], - "properties": { - "addressPrefix": "[variables('vnetSettings').subnets['aks-subnet'].addressPrefix]", - "delegations": [ - { - "name": "Microsoft.App.environments", - "id": "[concat(resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetSettings').name, 'aks-subnet'), '/delegations/Microsoft.App.environments')]", - "properties": { - "serviceName": "Microsoft.App/environments" - }, - "type": "Microsoft.Network/virtualNetworks/subnets/delegations" - } - ], - "privateEndpointNetworkPolicies": "Disabled", - "privateLinkServiceNetworkPolicies": "Enabled", - "networkSecurityGroup": { - "id": "[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('vnetSettings').name, '-aks-subnet-nsg'))]", - "name": "[concat(variables('vnetSettings').name, '-aks-subnet-nsg')]", - "properties": { - "flushConnection": false, - "securityRules": [ - { - "name": "AllowHTTPInbound", - "properties": { - "access": "Allow", - "destinationAddressPrefix": "*", - "destinationPortRange": "80", - "direction": "Inbound", - "priority": 500, - "protocol": "Tcp", - "sourceAddressPrefix": "Internet", - "sourcePortRange": "*" - }, - "type": "Microsoft.Network/networkSecurityGroups/securityRules" - }, - { - "name": "AllowHTTPSInbound", - "properties": { - "access": "Allow", - "destinationAddressPrefix": "*", - "destinationPortRange": "443", - "direction": "Inbound", - "priority": 501, - "protocol": "Tcp", - "sourceAddressPrefix": "Internet", - "sourcePortRange": "*" - }, - "type": "Microsoft.Network/networkSecurityGroups/securityRules" - } - ] - } - } - } - }, - { - "type": "Microsoft.Network/networkSecurityGroups", - "apiVersion": "2023-04-01", - "name": "[concat(variables('vnetSettings').name, '-aks-subnet-nsg')]", - "location": "[parameters('location')]", - "properties": { - "flushConnection": false, - "securityRules": [ - { - "name": "AllowHTTPInbound", - "properties": { - "access": "Allow", - "destinationAddressPrefix": "*", - "destinationPortRange": "80", - "direction": "Inbound", - "priority": 500, - "protocol": "Tcp", - "sourceAddressPrefix": "Internet", - "sourcePortRange": "*" - }, - "type": "Microsoft.Network/networkSecurityGroups/securityRules" - }, - { - "name": "AllowHTTPSInbound", - "properties": { - "access": "Allow", - "destinationAddressPrefix": "*", - "destinationPortRange": "443", - "direction": "Inbound", - "priority": 501, - "protocol": "Tcp", - "sourceAddressPrefix": "Internet", - "sourcePortRange": "*" - }, - "type": "Microsoft.Network/networkSecurityGroups/securityRules" - } - ] - } - }, - { - "type": "Microsoft.App/managedEnvironments", - "apiVersion": "2023-05-01", - "name": "[format('{0}acaenv', parameters('name'))]", - "location": "[parameters('location')]", - "properties": { - "vnetConfiguration": { - "internal": false, - "infrastructureSubnetId": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetSettings').name, 'aks-subnet')]" - }, - "appLogsConfiguration": { - "destination": "log-analytics", - "logAnalyticsConfiguration": { - "customerId": "[reference(resourceId('Microsoft.OperationalInsights/workspaces', variables('laSettings').name), '2021-12-01-preview').customerId]", - "sharedKey": "[listKeys(resourceId('Microsoft.OperationalInsights/workspaces', variables('laSettings').name), providers('Microsoft.OperationalInsights', 'workspaces').apiVersions[0]).primarySharedKey]" - } - }, - "zoneRedundant": false, - "workloadProfiles": [ - { - "workloadProfileType": "Consumption", - "name": "Consumption" - }, - { - "workloadProfileType": "E4", - "name": "Warm", - "minimumCount": 2, - "maximumCount": 10 - } - ], - "infrastructureResourceGroup": "[concat('ME_', resourceGroup().name)]", - "peerAuthentication": { - "mtls": { - "enabled": false - } - } - } - }, - { - "type": "Microsoft.App/containerapps", - "apiVersion": "2023-05-02-preview", - "name": "[format('{0}chatapiaca', parameters('name'))]", - "location": "[parameters('location')]", - "dependsOn": [ - "[resourceId('Microsoft.App/managedEnvironments', format('{0}acaenv', parameters('name')))]", - "[resourceId('Microsoft.Search/searchServices', variables('cognitiveSearchSettings').name)]", - "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbSettings').name)]", - "[resourceId('Microsoft.Storage/storageAccounts', format('{0}promptsa', parameters('name')))]" - ], - "identity": { - "type": "SystemAssigned" - }, - "properties": { - "managedEnvironmentId": "[resourceId('Microsoft.App/managedEnvironments', format('{0}acaenv', parameters('name')))]", - "environmentId": "[resourceId('Microsoft.App/managedEnvironments', format('{0}acaenv', parameters('name')))]", - "workloadProfileName": "Warm", - "configuration": { - "secrets": [], - "activeRevisionsMode": "Single", - "ingress": { - "external": true, - "targetPort": 80, - "exposedPort": 0, - "transport": "Auto", - "traffic": [ - { - "latestRevision": true, - "weight": 100 - } - ], - "allowInsecure": false, - "clientCertificateMode": "Ignore" - } - }, - "template": { - "containers": [ - { - "image": "mcr.microsoft.com/k8se/quickstart:latest", - "name": "[format('{0}chatapiaca', parameters('name'))]", - "env": [ - { - "name": "ASPNETCORE_ENVIRONMENT", - "value": "Production" - }, - { - "name": "MSCosmosDBOpenAI__CognitiveSearch__IndexName", - "value": "vector-index" - }, - { - "name": "MSCosmosDBOpenAI__CognitiveSearch__MaxVectorSearchResults", - "value": "10" - }, - { - "name": "MSCosmosDBOpenAI__CognitiveSearch__Endpoint", - "value": "[concat('https://', variables('cognitiveSearchSettings').name, '.search.windows.net/')]" - }, - { - "name": "MSCosmosDBOpenAI__CognitiveSearch__Key", - "value": "[listAdminKeys(resourceId('Microsoft.Search/searchServices', variables('cognitiveSearchSettings').name), '2022-09-01').primaryKey]" - }, - { - "name": "MSCosmosDBOpenAI__OpenAI__CompletionsDeployment", - "value": "[parameters('openAiCompletionsDeployment')]" - }, - { - "name": "MSCosmosDBOpenAI__OpenAI__CompletionsDeploymentMaxTokens", - "value": "8096" - }, - { - "name": "MSCosmosDBOpenAI__OpenAI__EmbeddingsDeployment", - "value": "[parameters('openAiEmbeddingsDeployment')]" - }, - { - "name": "MSCosmosDBOpenAI__OpenAI__EmbeddingsDeploymentMaxTokens", - "value": "8191" - }, - { - "name": "MSCosmosDBOpenAI__OpenAI__ChatCompletionPromptName", - "value": "RetailAssistant.Default" - }, - { - "name": "MSCosmosDBOpenAI__OpenAI__ShortSummaryPromptName", - "value": "Summarizer.TwoWords" - }, - { - "name": "MSCosmosDBOpenAI__OpenAI__PromptOptimization__CompletionsMinTokens", - "value": "50" - }, - { - "name": "MSCosmosDBOpenAI__OpenAI__PromptOptimization__CompletionsMaxTokens", - "value": "300" - }, - { - "name": "MSCosmosDBOpenAI__OpenAI__PromptOptimization__SystemMaxTokens", - "value": "1500" - }, - { - "name": "MSCosmosDBOpenAI__OpenAI__PromptOptimization__MemoryMinTokens", - "value": "1500" - }, - { - "name": "MSCosmosDBOpenAI__OpenAI__PromptOptimization__MemoryMaxTokens", - "value": "7000" - }, - { - "name": "MSCosmosDBOpenAI__OpenAI__PromptOptimization__MessagesMinTokens", - "value": "100" - }, - { - "name": "MSCosmosDBOpenAI__OpenAI__PromptOptimization__MessagesMaxTokens", - "value": "200" - }, - { - "name": "MSCosmosDBOpenAI__OpenAI__Endpoint", - "value": "[parameters('openAiEndpoint')]" - }, - { - "name": "MSCosmosDBOpenAI__OpenAI__Key", - "value": "[parameters('openAiKey')]" - }, - { - "name": "MSCosmosDBOpenAI__CosmosDB__Containers", - "value": "completions, customer, product" - }, - { - "name": "MSCosmosDBOpenAI__CosmosDB__MonitoredContainers", - "value": "customer, product" - }, - { - "name": "MSCosmosDBOpenAI__CosmosDB__Database", - "value": "database" - }, - { - "name": "MSCosmosDBOpenAI__CosmosDB__ChangeFeedLeaseContainer", - "value": "leases" - }, - { - "name": "MSCosmosDBOpenAI__CosmosDB__Endpoint", - "value": "[reference(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbSettings').name), providers('Microsoft.DocumentDB', 'databaseAccounts').apiVersions[0]).documentEndpoint]" - }, - { - "name": "MSCosmosDBOpenAI__CosmosDB__Key", - "value": "[listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbSettings').name), providers('Microsoft.DocumentDB', 'databaseAccounts').apiVersions[0]).primaryMasterKey]" - }, - { - "name": "MSCosmosDBOpenAI__DurableSystemPrompt__BlobStorageContainer", - "value": "system-prompt" - }, - { - "name": "MSCosmosDBOpenAI__DurableSystemPrompt__BlobStorageConnection", - "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', format('{0}promptsa', parameters('name')), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', format('{0}promptsa', parameters('name'))), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value, ';EndpointSuffix=core.windows.net')]" - }, - { - "name": "MSCosmosDBOpenAI__CognitiveSearchMemorySource__IndexName", - "value": "vector-index" - }, - { - "name": "MSCosmosDBOpenAI__CognitiveSearchMemorySource__ConfigBlobStorageContainer", - "value": "memory-source" - }, - { - "name": "MSCosmosDBOpenAI__CognitiveSearchMemorySource__ConfigFilePath", - "value": "ACSMemorySourceConfig.json" - }, - { - "name": "MSCosmosDBOpenAI__CognitiveSearchMemorySource__Endpoint", - "value": "[concat('https://', variables('cognitiveSearchSettings').name, '.search.windows.net/')]" - }, - { - "name": "MSCosmosDBOpenAI__CognitiveSearchMemorySource__Key", - "value": "[listAdminKeys(resourceId('Microsoft.Search/searchServices', variables('cognitiveSearchSettings').name), '2022-09-01').primaryKey]" - }, - { - "name": "MSCosmosDBOpenAI__CognitiveSearchMemorySource__ConfigBlobStorageConnection", - "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', format('{0}promptsa', parameters('name')), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', format('{0}promptsa', parameters('name'))), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value, ';EndpointSuffix=core.windows.net')]" - }, - { - "name": "MSCosmosDBOpenAI__BlobStorageMemorySource__ConfigBlobStorageContainer", - "value": "memory-source" - }, - { - "name": "MSCosmosDBOpenAI__BlobStorageMemorySource__ConfigFilePath", - "value": "BlobMemorySourceConfig.json" - }, - { - "name": "MSCosmosDBOpenAI__BlobStorageMemorySource__ConfigBlobStorageConnection", - "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', format('{0}promptsa', parameters('name')), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', format('{0}promptsa', parameters('name'))), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value, ';EndpointSuffix=core.windows.net')]" - }, - { - "name": "ApplicationInsights__ConnectionString", - "value": "[reference(resourceId('Microsoft.Insights/components', variables('aiSettings').name), providers('Microsoft.Insights', 'components').apiVersions[0]).connectionString]" - } - ], - "resources": { - "cpu": 0.5, - "memory": "1Gi" - }, - "probes": [], - "volumeMounts": [] - } - ], - "scale": { - "minReplicas": 2, - "maxReplicas": 10 - }, - "volumes": [] - } - } - }, - { - "type": "Microsoft.App/containerapps", - "apiVersion": "2023-05-02-preview", - "name": "[format('{0}chatwebaca', parameters('name'))]", - "location": "[parameters('location')]", - "dependsOn": [ - "[resourceId('Microsoft.App/managedEnvironments', format('{0}acaenv', parameters('name')))]", - "[resourceId('Microsoft.App/containerapps', format('{0}chatapiaca', parameters('name')))]" - ], - "identity": { - "type": "SystemAssigned" - }, - "properties": { - "managedEnvironmentId": "[resourceId('Microsoft.App/managedEnvironments', format('{0}acaenv', parameters('name')))]", - "environmentId": "[resourceId('Microsoft.App/managedEnvironments', format('{0}acaenv', parameters('name')))]", - "workloadProfileName": "Warm", - "configuration": { - "secrets": [], - "activeRevisionsMode": "Single", - "ingress": { - "external": true, - "targetPort": 80, - "exposedPort": 0, - "stickySessions": { - "affinity": "sticky" - }, - "transport": "Auto", - "traffic": [ - { - "latestRevision": true, - "weight": 100 - } - ], - "allowInsecure": false, - "clientCertificateMode": "Ignore" - } - }, - "template": { - "containers": [ - { - "image": "mcr.microsoft.com/k8se/quickstart:latest", - "name": "[format('{0}chatapiaca', parameters('name'))]", - "env": [ - { - "name": "ASPNETCORE_ENVIRONMENT", - "value": "Production" - }, - { - "name": "MSCosmosDBOpenAI__ChatManager__APIRoutePrefix", - "value": "" - }, - { - "name": "MSCosmosDBOpenAI__ChatManager__APIUrl", - "value": "[concat('https://', reference(resourceId('Microsoft.App/containerApps', format('{0}chatapiaca', parameters('name'))), providers('Microsoft.App', 'containerApps').apiVersions[0]).configuration.ingress.fqdn)]" - }, - { - "name": "ApplicationInsights__ConnectionString", - "value": "[reference(resourceId('Microsoft.Insights/components', variables('aiSettings').name), providers('Microsoft.Insights', 'components').apiVersions[0]).connectionString]" - } - ], - "resources": { - "cpu": 0.5, - "memory": "1Gi" - }, - "probes": [], - "volumeMounts": [] - } - ], - "scale": { - "minReplicas": 2, - "maxReplicas": 10 - }, - "volumes": [] - } - } - } - ], - "outputs": { - "webUrl": { - "type": "string", - "value": "[concat('https://', reference(resourceId('Microsoft.App/containerApps', format('{0}chatwebaca', parameters('name'))), providers('Microsoft.App', 'containerApps').apiVersions[0]).configuration.ingress.fqdn)]" - }, - "webFqdn": { - "type": "string", - "value": "[reference(resourceId('Microsoft.App/containerApps', format('{0}chatwebaca', parameters('name'))), providers('Microsoft.App', 'containerApps').apiVersions[0]).configuration.ingress.fqdn]" - }, - "apiFqdn": { - "type": "string", - "value": "[reference(resourceId('Microsoft.App/containerApps', format('{0}chatapiaca', parameters('name'))), providers('Microsoft.App', 'containerApps').apiVersions[0]).configuration.ingress.fqdn]" - }, - "apiAcaName": { - "type": "string", - "value": "[format('{0}chatapiaca', parameters('name'))]" - }, - "webAcaName": { - "type": "string", - "value": "[format('{0}chatwebaca', parameters('name'))]" - }, - "resourcePrefix": { - "type": "string", - "value": "[parameters('name')]" - }, - "cosmosDbAccountName": { - "type": "string", - "value": "[variables('cosmosDbSettings').name]" - } - } -} \ No newline at end of file diff --git a/arm/azuredeploy.json b/arm/azuredeploy.json deleted file mode 100644 index 7a41462..0000000 --- a/arm/azuredeploy.json +++ /dev/null @@ -1,652 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.17.1.54307", - "templateHash": "5692427675602515188" - } - }, - "parameters": { - "location": { - "type": "string", - "defaultValue": "eastus", - "allowedValues": [ - "southcentralus", - "eastus", - "westeurope" - ], - "metadata": { - "description": "Location where all resources will be deployed. This value defaults to the **East US** region." - } - }, - "name": { - "type": "string", - "defaultValue": "[uniqueString(resourceGroup().id)]", - "maxLength": 15, - "metadata": { - "description": "Unique name for the deployed services below. Max length 15 characters, alphanumeric only:\r\n- Azure Cosmos DB for NoSQL\r\n- Azure Cosmos DB for MongoDB vCore\r\n- Azure OpenAI\r\n- Azure App Service\r\n- Azure Functions\r\n\r\nThe name defaults to a unique string generated from the resource group identifier.\r\n" - } - }, - "k8sVersion": { - "type": "string", - "defaultValue": "1.27.3", - "metadata": { - "description": "Specifies the version of Kubernetes to use for the Azure Kubernetes Service (AKS) cluster. Defaults to **1.27.3**" - } - } - }, - "variables": { - "cosmosDbSettings": { - "name": "[format('{0}-cosmos-nosql', parameters('name'))]", - "databaseName": "database" - }, - "cognitiveSearchSettings": { - "name": "[format('{0}-cog-search', parameters('name'))]", - "sku": "basic" - }, - "cosmosContainers": { - "embeddingContainer": { - "name": "embedding", - "partitionKeyPath": "/id", - "maxThroughput": 1000 - }, - "completionsContainer": { - "name": "completions", - "partitionKeyPath": "/sessionId", - "maxThroughput": 1000 - }, - "productContainer": { - "name": "product", - "partitionKeyPath": "/categoryId", - "maxThroughput": 1000 - }, - "customerContainer": { - "name": "customer", - "partitionKeyPath": "/customerId", - "maxThroughput": 1000 - }, - "leasesContainer": { - "name": "leases", - "partitionKeyPath": "/id", - "maxThroughput": 1000 - } - }, - "vnetSettings": { - "name": "[format('{0}-vnet', parameters('name'))]", - "addressPrefix": "10.244.0.0/16", - "subnets": { - "aks-subnet": { - "addressPrefix": "10.244.0.0/16" - } - } - }, - "acrSettings": { - "name": "[format('{0}cr', parameters('name'))]", - "sku": "Standard", - "tier": "Standard" - }, - "aksSettings": { - "name": "[format('{0}-aks', parameters('name'))]", - "kubeletIdentityName": "[format('{0}-aks-agentpool', parameters('name'))]", - "nodeRG": "[format('MC_{0}', parameters('name'))]", - "sku": "Basic", - "tier": "Free" - }, - "laSettings": { - "name": "[format('{0}-la', parameters('name'))]" - }, - "aiSettings": { - "name": "[format('{0}-ai', parameters('name'))]" - } - }, - "resources": [ - { - "type": "Microsoft.DocumentDB/databaseAccounts", - "apiVersion": "2022-08-15", - "name": "[variables('cosmosDbSettings').name]", - "location": "[parameters('location')]", - "kind": "GlobalDocumentDB", - "properties": { - "consistencyPolicy": { - "defaultConsistencyLevel": "Session" - }, - "databaseAccountOfferType": "Standard", - "locations": [ - { - "failoverPriority": 0, - "isZoneRedundant": false, - "locationName": "[parameters('location')]" - } - ] - } - }, - { - "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases", - "apiVersion": "2022-08-15", - "name": "[format('{0}/{1}', variables('cosmosDbSettings').name, variables('cosmosDbSettings').databaseName)]", - "properties": { - "resource": { - "id": "[variables('cosmosDbSettings').databaseName]" - } - }, - "dependsOn": [ - "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbSettings').name)]" - ] - }, - { - "copy": { - "name": "cosmosContainer", - "count": "[length(items(variables('cosmosContainers')))]" - }, - "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers", - "apiVersion": "2022-08-15", - "name": "[format('{0}/{1}/{2}', variables('cosmosDbSettings').name, variables('cosmosDbSettings').databaseName, items(variables('cosmosContainers'))[copyIndex()].value.name)]", - "properties": { - "resource": { - "id": "[items(variables('cosmosContainers'))[copyIndex()].value.name]", - "partitionKey": { - "paths": [ - "[items(variables('cosmosContainers'))[copyIndex()].value.partitionKeyPath]" - ], - "kind": "Hash", - "version": 2 - } - }, - "options": { - "autoscaleSettings": { - "maxThroughput": "[items(variables('cosmosContainers'))[copyIndex()].value.maxThroughput]" - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', variables('cosmosDbSettings').name, variables('cosmosDbSettings').databaseName)]" - ] - }, - { - "type": "Microsoft.Search/searchServices", - "apiVersion": "2022-09-01", - "name": "[variables('cognitiveSearchSettings').name]", - "location": "[parameters('location')]", - "sku": { - "name": "[variables('cognitiveSearchSettings').sku]" - }, - "properties": { - "replicaCount": 1, - "partitionCount": 1, - "hostingMode": "default", - "publicNetworkAccess": "Enabled", - "networkRuleSet": { - "ipRules": [] - }, - "encryptionWithCmk": { - "enforcement": "Unspecified" - }, - "disableLocalAuth": false, - "authOptions": { - "apiKeyOnly": {} - } - } - }, - { - "type": "Microsoft.Network/virtualNetworks", - "apiVersion": "2022-09-01", - "name": "[variables('vnetSettings').name]", - "location": "[parameters('location')]", - "properties": { - "addressSpace": { - "addressPrefixes": [ - "[variables('vnetSettings').addressPrefix]" - ] - }, - "subnets": [ - { - "name": "aks-subnet", - "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetSettings').name, 'aks-subnet')]", - "properties": { - "addressPrefix": "[variables('vnetSettings').subnets['aks-subnet'].addressPrefix]", - "delegations": [], - "privateEndpointNetworkPolicies": "Disabled", - "privateLinkServiceNetworkPolicies": "Enabled" - }, - "type": "Microsoft.Network/virtualNetworks/subnets" - } - ], - "virtualNetworkPeerings": [], - "enableDdosProtection": false - } - }, - { - "type": "Microsoft.ContainerRegistry/registries", - "apiVersion": "2023-01-01-preview", - "name": "[variables('acrSettings').name]", - "location": "[parameters('location')]", - "sku": { - "name": "[variables('acrSettings').sku]", - "tier": "[variables('acrSettings').tier]" - }, - "properties": { - "adminUserEnabled": true, - "policies": { - "quarantinePolicy": { - "status": "disabled" - }, - "trustPolicy": { - "type": "Notary", - "status": "disabled" - }, - "retentionPolicy": { - "days": 7, - "status": "disabled" - }, - "exportPolicy": { - "status": "enabled" - }, - "azureADAuthenticationAsArmPolicy": { - "status": "enabled" - }, - "softDeletePolicy": { - "retentionDays": 7, - "status": "disabled" - } - }, - "encryption": { - "status": "disabled" - }, - "dataEndpointEnabled": false, - "publicNetworkAccess": "Enabled", - "networkRuleBypassOptions": "AzureServices", - "zoneRedundancy": "Disabled", - "anonymousPullEnabled": true - } - }, - { - "type": "Microsoft.ContainerRegistry/registries/scopeMaps", - "apiVersion": "2023-01-01-preview", - "name": "[concat(variables('acrSettings').name, '/_repositories_admin')]", - "dependsOn": [ - "[resourceId('Microsoft.ContainerRegistry/registries', variables('acrSettings').name)]" - ], - "properties": { - "description": "Can perform all read, write and delete operations on the registry", - "actions": [ - "repositories/*/metadata/read", - "repositories/*/metadata/write", - "repositories/*/content/read", - "repositories/*/content/write", - "repositories/*/content/delete" - ] - } - }, - { - "type": "Microsoft.ContainerRegistry/registries/scopeMaps", - "apiVersion": "2023-01-01-preview", - "name": "[concat(variables('acrSettings').name, '/_repositories_pull')]", - "dependsOn": [ - "[resourceId('Microsoft.ContainerRegistry/registries', variables('acrSettings').name)]" - ], - "properties": { - "description": "Can pull any repository of the registry", - "actions": [ - "repositories/*/content/read" - ] - } - }, - { - "type": "Microsoft.ContainerRegistry/registries/scopeMaps", - "apiVersion": "2023-01-01-preview", - "name": "[concat(variables('acrSettings').name, '/_repositories_push')]", - "dependsOn": [ - "[resourceId('Microsoft.ContainerRegistry/registries', variables('acrSettings').name)]" - ], - "properties": { - "description": "Can push to any repository of the registry", - "actions": [ - "repositories/*/content/read", - "repositories/*/content/write" - ] - } - }, - { - "type": "Microsoft.OperationalInsights/workspaces", - "apiVersion": "2021-12-01-preview", - "name": "[variables('laSettings').name]", - "location": "eastus", - "properties": { - "sku": { - "name": "Standalone" - }, - "retentionInDays": 31, - "features": { - "enableLogAccessUsingOnlyResourcePermissions": true - }, - "workspaceCapping": { - "dailyQuotaGb": -1 - }, - "publicNetworkAccessForIngestion": "Enabled", - "publicNetworkAccessForQuery": "Enabled" - } - }, - { - "type": "Microsoft.Insights/components", - "apiVersion": "2020-02-02", - "name": "[variables('aiSettings').name]", - "location": "[parameters('location')]", - "kind": "web", - "properties": { - "Application_Type": "web", - "Flow_Type": "Bluefield", - "Request_Source": "rest", - "RetentionInDays": 30, - "WorkspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces', variables('laSettings').name)]", - "IngestionMode": "LogAnalytics", - "publicNetworkAccessForIngestion": "Enabled", - "publicNetworkAccessForQuery": "Enabled" - }, - "dependsOn": [ - "[resourceId('Microsoft.OperationalInsights/workspaces', variables('laSettings').name)]" - ] - }, - { - "type": "Microsoft.ContainerService/managedClusters", - "apiVersion": "2023-01-02-preview", - "name": "[variables('aksSettings').name]", - "location": "eastus", - "dependsOn": [ - "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetSettings').name, 'aks-subnet')]", - "[resourceId('Microsoft.OperationalInsights/workspaces', variables('laSettings').name)]" - ], - "sku": { - "name": "Basic", - "tier": "Free" - }, - "identity": { - "type": "SystemAssigned" - }, - "properties": { - "kubernetesVersion": "[parameters('k8sVersion')]", - "dnsPrefix": "[concat(variables('aksSettings').name, '-dns')]", - "agentPoolProfiles": [ - { - "name": "agentpool", - "count": 1, - "vmSize": "Standard_B4ms", - "osDiskSizeGB": 128, - "osDiskType": "Managed", - "kubeletDiskType": "OS", - "vnetSubnetID": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetSettings').name, 'aks-subnet')]", - "maxPods": 110, - "type": "VirtualMachineScaleSets", - "availabilityZones": [ - "1" - ], - "maxCount": 2, - "minCount": 1, - "enableAutoScaling": true, - "powerState": { - "code": "Running" - }, - "orchestratorVersion": "[parameters('k8sVersion')]", - "enableNodePublicIP": false, - "enableCustomCATrust": false, - "mode": "System", - "osType": "Linux", - "osSKU": "Ubuntu", - "enableFIPS": false - } - ], - "servicePrincipalProfile": { - "clientId": "msi" - }, - "addonProfiles": { - "azureKeyvaultSecretsProvider": { - "enabled": true, - "config": { - "enableSecretRotation": "true", - "rotationPollInterval": "2m" - } - }, - "azurepolicy": { - "enabled": false - }, - "httpApplicationRouting": { - "enabled": true - }, - "omsagent": { - "enabled": true, - "config": { - "logAnalyticsWorkspaceResourceID": "[resourceId('Microsoft.OperationalInsights/workspaces', variables('laSettings').name)]", - "useAADAuth": "true" - } - } - }, - "nodeResourceGroup": "[variables('aksSettings').nodeRG]", - "enableRBAC": true, - "networkProfile": { - "networkPlugin": "azure", - "networkPolicy": "azure", - "loadBalancerSku": "Standard", - "loadBalancerProfile": { - "managedOutboundIPs": { - "count": 1 - }, - "backendPoolType": "nodeIPConfiguration" - }, - "serviceCidr": "10.0.0.0/16", - "dnsServiceIP": "10.0.0.10", - "dockerBridgeCidr": "172.17.0.1/16", - "outboundType": "loadBalancer", - "serviceCidrs": [ - "10.0.0.0/16" - ], - "ipFamilies": [ - "IPv4" - ] - }, - "autoScalerProfile": { - "balance-similar-node-groups": "false", - "expander": "random", - "max-empty-bulk-delete": "10", - "max-graceful-termination-sec": "600", - "max-node-provision-time": "15m", - "max-total-unready-percentage": "45", - "new-pod-scale-up-delay": "0s", - "ok-total-unready-count": "3", - "scale-down-delay-after-add": "10m", - "scale-down-delay-after-delete": "10s", - "scale-down-delay-after-failure": "3m", - "scale-down-unneeded-time": "10m", - "scale-down-unready-time": "20m", - "scale-down-utilization-threshold": "0.5", - "scan-interval": "10s", - "skip-nodes-with-local-storage": "false", - "skip-nodes-with-system-pods": "true" - }, - "autoUpgradeProfile": { - "upgradeChannel": "patch" - }, - "disableLocalAccounts": false, - "securityProfile": {}, - "storageProfile": { - "diskCSIDriver": { - "enabled": true, - "version": "v1" - }, - "fileCSIDriver": { - "enabled": true - }, - "snapshotController": { - "enabled": true - } - }, - "oidcIssuerProfile": { - "enabled": false - }, - "ingressProfile": { - "webAppRouting": { - "enabled": true - } - }, - "workloadAutoScalerProfile": {}, - "azureMonitorProfile": { - "metrics": { - "enabled": true, - "kubeStateMetrics": {} - } - } - } - }, - { - "type": "Microsoft.Storage/storageAccounts", - "apiVersion": "2021-09-01", - "name": "[format('{0}promptsa', parameters('name'))]", - "location": "[parameters('location')]", - "kind": "Storage", - "sku": { - "name": "Standard_LRS" - } - }, - { - "type": "Microsoft.Network/virtualNetworks/subnets", - "apiVersion": "2022-09-01", - "name": "[concat(variables('vnetSettings').name, '/aks-subnet')]", - "dependsOn": [ - "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetSettings').name)]", - "[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('vnetSettings').name, '-aks-subnet-nsg'))]" - ], - "properties": { - "addressPrefix": "[variables('vnetSettings').subnets['aks-subnet'].addressPrefix]", - "delegations": [], - "privateEndpointNetworkPolicies": "Disabled", - "privateLinkServiceNetworkPolicies": "Enabled", - "networkSecurityGroup": { - "id": "[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('vnetSettings').name, '-aks-subnet-nsg'))]", - "name": "[concat(variables('vnetSettings').name, '-aks-subnet-nsg')]", - "properties": { - "flushConnection": false, - "securityRules": [ - { - "name": "AllowHTTPInbound", - "properties": { - "access": "Allow", - "destinationAddressPrefix": "*", - "destinationPortRange": "80", - "direction": "Inbound", - "priority": 500, - "protocol": "Tcp", - "sourceAddressPrefix": "Internet", - "sourcePortRange": "*" - }, - "type": "Microsoft.Network/networkSecurityGroups/securityRules" - }, - { - "name": "AllowHTTPSInbound", - "properties": { - "access": "Allow", - "destinationAddressPrefix": "*", - "destinationPortRange": "443", - "direction": "Inbound", - "priority": 501, - "protocol": "Tcp", - "sourceAddressPrefix": "Internet", - "sourcePortRange": "*" - }, - "type": "Microsoft.Network/networkSecurityGroups/securityRules" - } - ] - } - } - } - }, - { - "type": "Microsoft.Network/networkSecurityGroups", - "apiVersion": "2023-04-01", - "name": "[concat(variables('vnetSettings').name, '-aks-subnet-nsg')]", - "location": "[parameters('location')]", - "properties": { - "flushConnection": false, - "securityRules": [ - { - "name": "AllowHTTPInbound", - "properties": { - "access": "Allow", - "destinationAddressPrefix": "*", - "destinationPortRange": "80", - "direction": "Inbound", - "priority": 500, - "protocol": "Tcp", - "sourceAddressPrefix": "Internet", - "sourcePortRange": "*" - }, - "type": "Microsoft.Network/networkSecurityGroups/securityRules" - }, - { - "name": "AllowHTTPSInbound", - "properties": { - "access": "Allow", - "destinationAddressPrefix": "*", - "destinationPortRange": "443", - "direction": "Inbound", - "priority": 501, - "protocol": "Tcp", - "sourceAddressPrefix": "Internet", - "sourcePortRange": "*" - }, - "type": "Microsoft.Network/networkSecurityGroups/securityRules" - } - ] - } - }, - { - "type": "Microsoft.ContainerService/managedClusters/agentPools", - "apiVersion": "2023-01-02-preview", - "name": "[concat(variables('aksSettings').name, '/agentpool')]", - "dependsOn": [ - "[resourceId('Microsoft.ContainerService/managedClusters', variables('aksSettings').name)]", - "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetSettings').name, 'aks-subnet')]" - ], - "properties": { - "count": 1, - "vmSize": "Standard_B4ms", - "osDiskSizeGB": 128, - "osDiskType": "Managed", - "kubeletDiskType": "OS", - "maxPods": 110, - "type": "VirtualMachineScaleSets", - "availabilityZones": [ - "1", - "2", - "3" - ], - "maxCount": 2, - "minCount": 1, - "enableAutoScaling": true, - "powerState": { - "code": "Running" - }, - "orchestratorVersion": "[parameters('k8sVersion')]", - "enableNodePublicIP": false, - "enableCustomCATrust": false, - "mode": "System", - "osType": "Linux", - "osSKU": "Ubuntu", - "enableFIPS": false - } - } - ], - "outputs": { - "deployedUrl": { - "type": "string", - "value": "[reference(resourceId('Microsoft.ContainerService/managedClusters', variables('aksSettings').name), '2023-01-02-preview').addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName]" - }, - "resourcePrefix": { - "type": "string", - "value": "[parameters('name')]" - }, - "cosmosDbAccountName": { - "type": "string", - "value": "[variables('cosmosDbSettings').name]" - } - } -} \ No newline at end of file diff --git a/arm/vmdeploy.json b/arm/vmdeploy.json deleted file mode 100644 index 119ef42..0000000 --- a/arm/vmdeploy.json +++ /dev/null @@ -1,236 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "location": { - "type": "string", - "defaultValue": "eastus", - "metadata": { - "description": "Location where all resources will be deployed. This value defaults to the **East US** region." - } - }, - "name": { - "type": "string", - "defaultValue": "[uniqueString(resourceGroup().id)]", - "maxLength": 15, - "metadata": { - "description": "Unique name for the deployed services below. Max length 15 characters, alphanumeric only:\r\n- Azure Cosmos DB for NoSQL\r\n- Azure Cosmos DB for MongoDB vCore\r\n- Azure OpenAI\r\n- Azure App Service\r\n- Azure Functions\r\n\r\nThe name defaults to a unique string generated from the resource group identifier.\r\n" - } - }, - "password": { - "type": "securestring", - "metadata": { - "description": "Password for the Azure VM. The password must be at least 12 characters long and meet the complexity requirements of Azure VMs." - } - } - }, - "variables": { - "vnetSettings": { - "name": "[format('{0}-vnet', parameters('name'))]" - }, - "nsgSettings": { - "name": "[format('{0}-nsg', parameters('name'))]" - }, - "publicIpSettings": { - "name": "[format('{0}-ip', parameters('name'))]" - }, - "vmSettings": { - "name": "[format('{0}vm', parameters('name'))]" - }, - "nicSettings": { - "name": "[format('{0}-nic', parameters('name'))]" - } - }, - "resources": [ - { - "type": "Microsoft.Network/networkSecurityGroups", - "apiVersion": "2019-02-01", - "name": "[variables('nsgSettings').name]", - "location": "[parameters('location')]", - "properties": { - "securityRules": [ - { - "name": "RDP", - "id": "[resourceId('Microsoft.Network/networkSecurityGroups/securityRules', variables('nsgSettings').name, 'RDP')]", - "type": "Microsoft.Network/networkSecurityGroups/securityRules", - "properties": { - "protocol": "TCP", - "sourcePortRange": "*", - "destinationPortRange": "3389", - "sourceAddressPrefix": "*", - "destinationAddressPrefix": "*", - "access": "Allow", - "priority": 300, - "direction": "Inbound", - "sourcePortRanges": [], - "destinationPortRanges": [], - "sourceAddressPrefixes": [], - "destinationAddressPrefixes": [] - } - } - ] - } - }, - { - "type": "Microsoft.Network/publicIPAddresses", - "apiVersion": "2020-08-01", - "name": "[variables('publicIpSettings').name]", - "location": "[parameters('location')]", - "sku": { - "name": "Standard" - }, - "properties": { - "publicIPAllocationMethod": "Static" - } - }, - { - "type": "Microsoft.Network/virtualNetworks", - "apiVersion": "2021-05-01", - "name": "[variables('vnetSettings').name]", - "location": "[parameters('location')]", - "properties": { - "addressSpace": { - "addressPrefixes": [ - "10.2.0.0/16" - ] - }, - "subnets": [ - { - "name": "default", - "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetSettings').name, 'default')]", - "properties": { - "addressPrefix": "10.2.0.0/24", - "delegations": [], - "privateEndpointNetworkPolicies": "Disabled", - "privateLinkServiceNetworkPolicies": "Enabled" - }, - "type": "Microsoft.Network/virtualNetworks/subnets" - } - ], - "virtualNetworkPeerings": [], - "enableDdosProtection": false - } - }, - { - "type": "Microsoft.Compute/virtualMachines", - "apiVersion": "2022-03-01", - "name": "[variables('vmSettings').name]", - "location": "[parameters('location')]", - "dependsOn": [ - "[resourceId('Microsoft.Network/networkInterfaces', variables('nicSettings').name)]" - ], - "properties": { - "hardwareProfile": { - "vmSize": "Standard_D4s_v3" - }, - "storageProfile": { - "imageReference": { - "publisher": "microsoftvisualstudio", - "offer": "visualstudio2022", - "sku": "vs-2022-comm-latest-ws2022", - "version": "latest" - }, - "osDisk": { - "createOption": "FromImage", - "managedDisk": { - "storageAccountType": "Premium_LRS" - }, - "deleteOption": "Delete" - } - }, - "osProfile": { - "computerName": "[variables('vmSettings').name]", - "adminUsername": "BYDtoChatGPTUser", - "adminPassword": "[parameters('password')]", - "windowsConfiguration": { - "provisionVMAgent": true, - "enableAutomaticUpdates": true, - "patchSettings": { - "patchMode": "AutomaticByOS", - "enableHotpatching": false - } - } - }, - "networkProfile": { - "networkInterfaces": [ - { - "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicSettings').name)]", - "properties": { - "deleteOption": "Delete" - } - } - ] - } - } - }, - { - "type": "Microsoft.Network/networkInterfaces", - "apiVersion": "2022-09-01", - "name": "[variables('nicSettings').name]", - "location": "[parameters('location')]", - "dependsOn": [ - "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIpSettings').name)]", - "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgSettings').name)]" - ], - "kind": "Regular", - "properties": { - "ipConfigurations": [ - { - "name": "ipconfig1", - "id": "[concat(resourceId('Microsoft.Network/networkInterfaces', variables('nicSettings').name), '/ipConfigurations/ipconfig1')]", - "type": "Microsoft.Network/networkInterfaces/ipConfigurations", - "properties": { - "privateIPAllocationMethod": "Dynamic", - "publicIPAddress": { - "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIpSettings').name)]", - "properties": { - "deleteOption": "Delete" - } - }, - "subnet": { - "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetSettings').name, 'default')]" - }, - "primary": true, - "privateIPAddressVersion": "IPv4" - } - } - ], - "networkSecurityGroup": { - "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgSettings').name)]" - } - } - }, - { - "type": "Microsoft.Compute/virtualMachines/extensions", - "apiVersion": "2021-04-01", - "name": "[format('{0}/{1}', variables('vmSettings').name, 'VMScriptExtension')]", - "location": "[parameters('location')]", - "dependsOn": [ - "[format('Microsoft.Compute/virtualMachines/{0}',variables('vmSettings').name)]" - ], - "properties": { - "publisher": "Microsoft.Compute", - "type": "CustomScriptExtension", - "typeHandlerVersion": "1.9", - "autoUpgradeMinorVersion": true, - "protectedSettings": {}, - "settings": { - "fileUris": [ - "https://bydtochatgptsa.blob.core.windows.net/vmscripts/VMScriptExtension.ps1" - ], - "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File VMScriptExtension.ps1" - } - } - } - ], - "outputs": { - "deployedVM": { - "type": "string", - "value": "[variables('vmSettings').name]" - }, - "resourcePrefix": { - "type": "string", - "value": "[parameters('name')]" - } - } -} \ No newline at end of file diff --git a/azuredeploy.bicep b/azuredeploy.bicep deleted file mode 100644 index b0ddcb4..0000000 --- a/azuredeploy.bicep +++ /dev/null @@ -1,397 +0,0 @@ -@description('Location where all resources will be deployed. This value defaults to the **East US** region.') -@allowed([ - 'southcentralus' - 'eastus' - 'westeurope' -]) -param location string = 'eastus' - -@description(''' -Unique name for the deployed services below. Max length 15 characters, alphanumeric only: -- Azure Cosmos DB for NoSQL -- Azure Cosmos DB for MongoDB vCore -- Azure OpenAI -- Azure App Service -- Azure Functions - -The name defaults to a unique string generated from the resource group identifier. -''') -@maxLength(15) -param name string = uniqueString(resourceGroup().id) - -@description('Specifies the SKU for the Azure App Service plan. Defaults to **B1**') -@allowed([ - 'B1' - 'S1' -]) -param appServiceSku string = 'B1' - -@description('Specifies the SKU for the Azure OpenAI resource. Defaults to **S0**') -@allowed([ - 'S0' -]) -param openAiSku string = 'S0' - -@description('MongoDb vCore user Name. No dashes.') -param mongoDbUserName string - -@description('MongoDb vCore password. 8-256 characters, 3 of the following: lower case, upper case, numeric, symbol.') -@minLength(8) -@maxLength(256) -@secure() -param mongoDbPassword string - - -@description('Git repository URL for the application source. This defaults to the [`Azure/BuildYourOwnCopilot`](https://github.com/Azure/BuildYourOwnCopilot) repository.') -param appGitRepository string = 'https://github.com/Azure/BuildYourOwnCopilot.git' - -@description('Git repository branch for the application source. This defaults to the [**MongovCore** branch of the `Azure/BuildYourOwnCopilot`](https://github.com/Azure/BuildYourOwnCopilot/tree/MongovCore) repository.') -param appGetRepositoryBranch string = 'MongovCore' - -var openAiSettings = { - name: '${name}-openai' - sku: openAiSku - maxConversationBytes: '2000' - completionsModel: { - name: 'gpt-35-turbo' - version: '0301' - deployment: { - name: 'completions' - } - } - embeddingsModel: { - name: 'text-embedding-ada-002' - version: '2' - deployment: { - name: 'embeddings' - } - } -} - -var deployedRegion = { - 'East US': { - armName: toLower('eastus') - } - 'South Central US': { - armName: toLower('southcentralus') - } - 'West Europe': { - armName: toLower('westeurope') - } -} - -var cosmosDbSettings = { - name: '${name}-cosmos-nosql' - databaseName: 'vsai-database' -} - -var mongovCoreSettings = { - mongoClusterName: '${name}-mongo' - mongoClusterLogin: mongoDbUserName - mongoClusterPassword: mongoDbPassword -} - -var cosmosContainers = { - embeddingContainer: { - name: 'embedding' - partitionKeyPath : '/id' - } - completionsContainer: { - name: 'completions' - partitionKeyPath: '/sessionId' - } - productContainer: { - name: 'product' - partitionKeyPath: '/categoryId' - } - customerContainer: { - name: 'customer' - partitionKeyPath: '/customerId' - } - leasesContainer: { - name: 'leases' - partitionKeyPath: '/id' - } -} - -var appServiceSettings = { - plan: { - name: '${name}-web-plan' - sku: appServiceSku - } - web: { - name: '${name}-web' - git: { - repo: appGitRepository - branch: appGetRepositoryBranch - } - } - function: { - name: '${name}-function' - git: { - repo: appGitRepository - branch: appGetRepositoryBranch - } - } -} - -resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2022-08-15' = { - name: cosmosDbSettings.name - location: location - kind: 'GlobalDocumentDB' - properties: { - consistencyPolicy: { - defaultConsistencyLevel: 'Session' - } - databaseAccountOfferType: 'Standard' - locations: [ - { - failoverPriority: 0 - isZoneRedundant: false - locationName: location - } - ] - capabilities: [ - { - name: 'EnableServerless' - } - ] - } -} - -resource cosmosDatabase 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2022-08-15' = { - parent: cosmosDbAccount - name: cosmosDbSettings.databaseName - properties: { - resource: { - id: cosmosDbSettings.databaseName - } - } -} - -resource cosmosContainer 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2022-08-15' = [for container in items(cosmosContainers): { - parent: cosmosDatabase - name: container.value.name - properties: { - resource: { - id: container.value.name - partitionKey: { - paths: [ - container.value.partitionKeyPath - ] - kind: 'Hash' - version: 2 - } - } - } -}] - -resource mongoCluster 'Microsoft.DocumentDB/mongoClusters@2023-03-01-preview' = { - name: mongovCoreSettings.mongoClusterName - location: location - properties: { - administratorLogin: mongovCoreSettings.mongoClusterLogin - administratorLoginPassword: mongovCoreSettings.mongoClusterPassword - serverVersion: '5.0' - nodeGroupSpecs: [ - { - kind: 'Shard' - sku: 'M30' - diskSizeGB: 128 - enableHa: false - nodeCount: 1 - } - ] - } -} - -resource mongoFirewallRulesAllowAzure 'Microsoft.DocumentDB/mongoClusters/firewallRules@2023-03-01-preview' = { - parent: mongoCluster - name: 'allowAzure' - properties: { - startIpAddress: '0.0.0.0' - endIpAddress: '0.0.0.0' - } -} - -resource mongoFirewallRulesAllowAll 'Microsoft.DocumentDB/mongoClusters/firewallRules@2023-03-01-preview' = { - parent: mongoCluster - name: 'allowAll' - properties: { - startIpAddress: '0.0.0.0' - endIpAddress: '255.255.255.255' - } -} - -resource openAiAccount 'Microsoft.CognitiveServices/accounts@2022-12-01' = { - name: openAiSettings.name - location: location - sku: { - name: openAiSettings.sku - } - kind: 'OpenAI' - properties: { - customSubDomainName: openAiSettings.name - publicNetworkAccess: 'Enabled' - } -} - -resource openAiEmbeddingsModelDeployment 'Microsoft.CognitiveServices/accounts/deployments@2022-12-01' = { - parent: openAiAccount - name: openAiSettings.embeddingsModel.deployment.name - properties: { - model: { - format: 'OpenAI' - name: openAiSettings.embeddingsModel.name - version: openAiSettings.embeddingsModel.version - } - scaleSettings: { - scaleType: 'Standard' - } - } -} - -resource openAiCompletionsModelDeployment 'Microsoft.CognitiveServices/accounts/deployments@2022-12-01' = { - parent: openAiAccount - name: openAiSettings.completionsModel.deployment.name - properties: { - model: { - format: 'OpenAI' - name: openAiSettings.completionsModel.name - version: openAiSettings.completionsModel.version - } - scaleSettings: { - scaleType: 'Standard' - } - } -} - -resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = { - name: appServiceSettings.plan.name - location: location - sku: { - name: appServiceSettings.plan.sku - } -} - -resource appServiceWeb 'Microsoft.Web/sites@2022-03-01' = { - name: appServiceSettings.web.name - location: location - properties: { - serverFarmId: appServicePlan.id - httpsOnly: true - } -} - -resource storageAccount 'Microsoft.Storage/storageAccounts@2021-09-01' = { - name: '${name}fnstorage' - location: location - kind: 'Storage' - sku: { - name: 'Standard_LRS' - } -} - -resource appServiceFunction 'Microsoft.Web/sites@2022-03-01' = { - name: appServiceSettings.function.name - location: location - kind: 'functionapp' - properties: { - serverFarmId: appServicePlan.id - httpsOnly: true - siteConfig: { - alwaysOn: true - } - } - dependsOn: [ - storageAccount - ] -} - -resource appServiceWebSettings 'Microsoft.Web/sites/config@2022-03-01' = { - parent: appServiceWeb - name: 'appsettings' - kind: 'string' - properties: { - APPINSIGHTS_INSTRUMENTATIONKEY: appServiceWebInsights.properties.InstrumentationKey - COSMOSDB__ENDPOINT: cosmosDbAccount.properties.documentEndpoint - COSMOSDB__KEY: cosmosDbAccount.listKeys().primaryMasterKey - COSMOSDB__DATABASE: cosmosDatabase.name - COSMOSDB__CONTAINERS: 'completions,product,customer' - OPENAI__ENDPOINT: openAiAccount.properties.endpoint - OPENAI__KEY: openAiAccount.listKeys().key1 - OPENAI__EMBEDDINGSDEPLOYMENT: openAiEmbeddingsModelDeployment.name - OPENAI__COMPLETIONSDEPLOYMENT: openAiCompletionsModelDeployment.name - OPENAI__MAXCONVERSATIONBYTES: openAiSettings.maxConversationBytes - MONGODB__CONNECTION: 'mongodb+srv://${mongovCoreSettings.mongoClusterLogin}:${mongovCoreSettings.mongoClusterPassword}@${mongovCoreSettings.mongoClusterName}.mongocluster.cosmos.azure.com/?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000' - MONGODB__DATABASENAME: 'vectordb' - MONGODB__COLLECTIONNAME: 'vectors' - MONGODB__MAXVECTORSEARCHRESULTS: '10' - } -} - -resource appServiceFunctionSettings 'Microsoft.Web/sites/config@2022-03-01' = { - parent: appServiceFunction - name: 'appsettings' - kind: 'string' - properties: { - AzureWebJobsStorage: 'DefaultEndpointsProtocol=https;AccountName=${name}fnstorage;EndpointSuffix=core.windows.net;AccountKey=${storageAccount.listKeys().keys[0].value}' - APPINSIGHTS_INSTRUMENTATIONKEY: appServiceFunctionsInsights.properties.ConnectionString - FUNCTIONS_EXTENSION_VERSION: '~4' - FUNCTIONS_WORKER_RUNTIME: 'dotnet' - CosmosDBConnection: cosmosDbAccount.listConnectionStrings().connectionStrings[0].connectionString - OPENAI__ENDPOINT: openAiAccount.properties.endpoint - OPENAI__KEY: openAiAccount.listKeys().key1 - OPENAI__EMBEDDINGSDEPLOYMENT: openAiEmbeddingsModelDeployment.name - OPENAI__MAXTOKENS: '8191' - MONGODB__CONNECTION: 'mongodb+srv://${mongovCoreSettings.mongoClusterLogin}:${mongovCoreSettings.mongoClusterPassword}@${mongovCoreSettings.mongoClusterName}.mongocluster.cosmos.azure.com/?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000' - MONGODB__DATABASENAME: 'vectordb' - MONGODB__COLLECTIONNAME: 'vectors' - } -} - -resource appServiceWebDeployment 'Microsoft.Web/sites/sourcecontrols@2021-03-01' = { - parent: appServiceWeb - name: 'web' - properties: { - repoUrl: appServiceSettings.web.git.repo - branch: appServiceSettings.web.git.branch - isManualIntegration: true - } - dependsOn: [ - appServiceWebSettings - ] -} - -resource appServiceFunctionsDeployment 'Microsoft.Web/sites/sourcecontrols@2021-03-01' = { - parent: appServiceFunction - name: 'web' - properties: { - repoUrl: appServiceSettings.web.git.repo - branch: appServiceSettings.web.git.branch - isManualIntegration: true - } - dependsOn: [ - appServiceFunctionSettings - ] -} - -resource appServiceFunctionsInsights 'Microsoft.Insights/components@2020-02-02' = { - name: appServiceFunction.name - location: location - kind: 'web' - properties: { - Application_Type: 'web' - } -} - -resource appServiceWebInsights 'Microsoft.Insights/components@2020-02-02' = { - name: appServiceWeb.name - location: location - kind: 'web' - properties: { - Application_Type: 'web' - } -} - -output deployedUrl string = appServiceWeb.properties.defaultHostName diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml deleted file mode 100644 index ec47d9e..0000000 --- a/docker/docker-compose.yml +++ /dev/null @@ -1,28 +0,0 @@ -services: - api: - image: ${REGISTRY:-ms-openai-cosmosdb}/chat-service-api:${TAG:-latest} - build: - context: ../ - dockerfile: ./ChatServiceWebApi/Dockerfile - ports: - - "80:80" - environment: - DOTNET_URLS: http://+:80 - ASPNETCORE_ENVIRONMENT: Production - AllowedHosts: '*' - Logging__Loglevel__Default: 'Debug' - Logging__Loglevel__Microsoft__AspNetCore: 'Debug' - web: - image: ${REGISTRY:-ms-openai-cosmosdb}/chat-web-app:${TAG:-latest} - build: - context: ../ - dockerfile: ./Search/Dockerfile - ports: - - "8080:80" - environment: - DOTNET_URLS: http://+:80 - ASPNETCORE_ENVIRONMENT: Production - AllowedHosts: '*' - DetailedErrors: 'true' - Logging__Loglevel__Default: 'Debug' - Logging__Loglevel__Microsoft__AspNetCore: 'Debug' \ No newline at end of file diff --git a/gvalues.template.yml b/gvalues.template.yml deleted file mode 100644 index 4101468..0000000 --- a/gvalues.template.yml +++ /dev/null @@ -1,46 +0,0 @@ -cognitiveSearch: - key: '{{searchAdminKey}}' - endpoint: '{{searchEndpoint}}' - indexName: 'vector-index' - maxVectorSearchResults: 10 -openAi: - completionsDeployment: 'completions' - completionsDeploymentMaxTokens: 8096 - embeddingsDeployment: 'embeddings' - embeddingsDeploymentMaxTokens: 8191 - chatCompletionPromptName: 'RetailAssistant.Default' - shortSummaryPromptName: 'Summarizer.TwoWords' - promptOptimization: - completionsMinTokens: 50 - completionsMaxTokens: 300 - systemMaxTokens: 1500 - memoryMinTokens: 1500 - memoryMaxTokens: 7000 - messagesMinTokens: 100 - messagesMaxTokens: 200 - endpoint: '{{openAiEndpoint}}' - key: '{{openAiKey}}' -cosmosDb: - containers: 'completions, customer, product' - monitoredContainers: 'customer, product' - database: 'vsai-database' - changeFeedLeaseContainer: 'leases' - endpoint: '{{cosmosEndpoint}}' - key: '{{cosmosKey}}' -durableSystemPrompt: - blobStorageContainer: 'system-prompt' - blobStorageConnection: '{{blobStorageConnectionString}}' -cognitiveSearchMemorySource: - configBlobStorageContainer: 'memory-source' - configFilePath: 'ACSMemorySourceConfig.json' - configBlobStorageConnection: '{{blobStorageConnectionString}}' - key: '{{searchAdminKey}}' - endpoint: '{{searchEndpoint}}' -blobStorageMemorySource: - configBlobStorageContainer: 'memory-source' - configFilePath: 'BlobMemorySourceConfig.json' - configBlobStorageConnection: '{{blobStorageConnectionString}}' -apiUrl: {{apiUrl}} -routePrefix: /api -applicationInsights: - connectionString: "{{aiConnectionString}}" \ No newline at end of file diff --git a/helm/chat-service-web-api/.helmignore b/helm/chat-service-web-api/.helmignore deleted file mode 100644 index 0e8a0eb..0000000 --- a/helm/chat-service-web-api/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/helm/chat-service-web-api/Chart.yaml b/helm/chat-service-web-api/Chart.yaml deleted file mode 100644 index 84a1602..0000000 --- a/helm/chat-service-web-api/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -appVersion: "1.0" -description: A Helm chart for Kubernetes -name: chat-service-web-api -version: 0.1.0 diff --git a/helm/chat-service-web-api/templates/_helpers.tpl b/helm/chat-service-web-api/templates/_helpers.tpl deleted file mode 100644 index 42148d9..0000000 --- a/helm/chat-service-web-api/templates/_helpers.tpl +++ /dev/null @@ -1,40 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "chat-service-web-api.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "chat-service-web-api.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "chat-service-web-api.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{- define "chat-service-web-api.apihost" -}} -{{- if .Values.apihost -}} -{{- printf "%s" .Values.apihost -}} -{{- else -}} -{{- printf "%s" (index .Values.ingress.hosts 0) -}} -{{- end -}} -{{- end -}} \ No newline at end of file diff --git a/helm/chat-service-web-api/templates/configmap.yaml b/helm/chat-service-web-api/templates/configmap.yaml deleted file mode 100644 index 8b8f1e1..0000000 --- a/helm/chat-service-web-api/templates/configmap.yaml +++ /dev/null @@ -1,32 +0,0 @@ -{{- $name := include "chat-service-web-api.fullname" . -}} - -apiVersion: v1 -kind: ConfigMap -metadata: - name: "cfg-{{ $name }}" - labels: - app: {{ template "chat-service-web-api.name" . }} - chart: {{ template "chat-service-web-api.chart" .}} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -data: - MSCosmosDBOpenAI__OpenAI__CompletionsDeployment: {{ .Values.openAi.completionsDeployment }} - MSCosmosDBOpenAI__OpenAI__CompletionsDeploymentMaxTokens: {{ .Values.openAi.completionsDeploymentMaxTokens | quote }} - MSCosmosDBOpenAI__OpenAI__EmbeddingsDeployment: {{ .Values.openAi.embeddingsDeployment }} - MSCosmosDBOpenAI__OpenAI__EmbeddingsDeploymentMaxTokens: {{ .Values.openAi.embeddingsDeploymentMaxTokens | quote }} - MSCosmosDBOpenAI__OpenAI__ChatCompletionPromptName: {{ .Values.openAi.chatCompletionPromptName }} - MSCosmosDBOpenAI__OpenAI__ShortSummaryPromptName: {{ .Values.openAi.shortSummaryPromptName }} - MSCosmosDBOpenAI__OpenAI__PromptOptimization__CompletionsMinTokens: {{ .Values.openAi.promptOptimization.completionsMinTokens | quote }} - MSCosmosDBOpenAI__OpenAI__PromptOptimization__CompletionsMaxTokens: {{ .Values.openAi.promptOptimization.completionsMaxTokens | quote }} - MSCosmosDBOpenAI__OpenAI__PromptOptimization__SystemMaxTokens: {{ .Values.openAi.promptOptimization.systemMaxTokens | quote }} - MSCosmosDBOpenAI__OpenAI__PromptOptimization__MemoryMinTokens: {{ .Values.openAi.promptOptimization.memoryMinTokens | quote }} - MSCosmosDBOpenAI__OpenAI__PromptOptimization__MemoryMaxTokens: {{ .Values.openAi.promptOptimization.memoryMaxTokens | quote }} - MSCosmosDBOpenAI__OpenAI__PromptOptimization__MessagesMinTokens: {{ .Values.openAi.promptOptimization.messagesMinTokens | quote }} - MSCosmosDBOpenAI__OpenAI__PromptOptimization__MessagesMaxTokens: {{ .Values.openAi.promptOptimization.messagesMaxTokens | quote }} - MSCosmosDBOpenAI__CosmosDB__Containers: {{ .Values.cosmosDb.containers }} - MSCosmosDBOpenAI__CosmosDB__MonitoredContainers: {{ .Values.cosmosDb.monitoredContainers }} - MSCosmosDBOpenAI__CosmosDB__Database: {{ .Values.cosmosDb.database }} - MSCosmosDBOpenAI__CosmosDB__ChangeFeedLeaseContainer: {{ .Values.cosmosDb.changeFeedLeaseContainer }} - MSCosmosDBOpenAI__DurableSystemPrompt__BlobStorageContainer: {{ .Values.durableSystemPrompt.blobStorageContainer }} - MSCosmosDBOpenAI__BlobStorageMemorySource__ConfigBlobStorageContainer: {{ .Values.blobStorageMemorySource.configBlobStorageContainer }} - MSCosmosDBOpenAI__BlobStorageMemorySource__ConfigFilePath: {{ .Values.blobStorageMemorySource.configFilePath }} \ No newline at end of file diff --git a/helm/chat-service-web-api/templates/deployment.yaml b/helm/chat-service-web-api/templates/deployment.yaml deleted file mode 100644 index 5d0ab26..0000000 --- a/helm/chat-service-web-api/templates/deployment.yaml +++ /dev/null @@ -1,83 +0,0 @@ -{{- $name := include "chat-service-web-api.fullname" . -}} -{{- $cfgname := printf "%s-%s" "cfg" $name -}} -{{- $secretName := printf "%s-%s" "secret" $name -}} -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ template "chat-service-web-api.fullname" . }} - labels: - app: {{ template "chat-service-web-api.name" . }} - chart: {{ template "chat-service-web-api.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - app: {{ template "chat-service-web-api.name" . }} - release: {{ .Release.Name }} - template: - metadata: - annotations: - rollme: {{ randAlphaNum 5 | quote }} - labels: - app: {{ template "chat-service-web-api.name" . }} - release: {{ .Release.Name }} - spec: - {{ if .Values.serviceaccount -}} - serviceAccountName: {{ .Values.serviceaccount }} - {{ if .Values.imagePullSecrets -}} - imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} - {{- end }} - {{- end }} - containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - env: - {{- if .Values.env.values -}} - {{- range .Values.env.values }} - - name: {{ .name }} - value: {{ .value | quote }} - {{- end -}} - {{- end -}} - {{- if .Values.env.configmap -}} - {{- range .Values.env.configmap }} - - name: {{ .name }} - valueFrom: - configMapKeyRef: - name: {{ $cfgname }} - key: {{ .name }} - {{- end -}} - {{- end }} - {{- if .Values.env.secret -}} - {{- range .Values.env.secret }} - - name: {{ .name }} - valueFrom: - secretKeyRef: - name: {{ $secretName }} - key: {{ .name }} - {{- end -}} - {{- end }} - ports: - - name: http - containerPort: 80 - protocol: TCP - resources: -{{ toYaml .Values.resources | indent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: -{{ toYaml . | indent 8 }} - {{- end }} - diff --git a/helm/chat-service-web-api/templates/ingress.yaml b/helm/chat-service-web-api/templates/ingress.yaml deleted file mode 100644 index f15356a..0000000 --- a/helm/chat-service-web-api/templates/ingress.yaml +++ /dev/null @@ -1,41 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "chat-service-web-api.fullname" . -}} - -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app: {{ template "chat-service-web-api.name" . }} - chart: {{ template "chat-service-web-api.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} - http: - paths: - - path: /api(/|$)(.*) - pathType: Prefix - backend: - service: - name: {{ $fullName }} - port: - number: 80 - {{- end }} -{{- end }} diff --git a/helm/chat-service-web-api/templates/secret.yaml b/helm/chat-service-web-api/templates/secret.yaml deleted file mode 100644 index 00425ba..0000000 --- a/helm/chat-service-web-api/templates/secret.yaml +++ /dev/null @@ -1,20 +0,0 @@ -{{- $name := include "chat-service-web-api.fullname" . -}} - -apiVersion: v1 -kind: Secret -metadata: - name: "secret-{{ $name }}" - labels: - app: {{ template "chat-service-web-api.name" . }} - chart: {{ template "chat-service-web-api.chart" .}} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -type: Opaque -data: - MSCosmosDBOpenAI__OpenAI__Endpoint: {{ .Values.openAi.endpoint | b64enc }} - MSCosmosDBOpenAI__OpenAI__Key: {{ .Values.openAi.key | b64enc }} - MSCosmosDBOpenAI__CosmosDB__Endpoint: {{ .Values.cosmosDb.endpoint | b64enc }} - MSCosmosDBOpenAI__CosmosDB__Key: {{ .Values.cosmosDb.key | b64enc }} - MSCosmosDBOpenAI__DurableSystemPrompt__BlobStorageConnection: {{ .Values.durableSystemPrompt.blobStorageConnection | b64enc }} - MSCosmosDBOpenAI__BlobStorageMemorySource__ConfigBlobStorageConnection: {{ .Values.blobStorageMemorySource.configBlobStorageConnection | b64enc }} - ApplicationInsights__ConnectionString: {{ .Values.applicationInsights.connectionString | b64enc }} \ No newline at end of file diff --git a/helm/chat-service-web-api/templates/service.yaml b/helm/chat-service-web-api/templates/service.yaml deleted file mode 100644 index 96d6552..0000000 --- a/helm/chat-service-web-api/templates/service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ template "chat-service-web-api.fullname" . }} - labels: - app: {{ template "chat-service-web-api.name" . }} - chart: {{ template "chat-service-web-api.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - app: {{ template "chat-service-web-api.name" . }} - release: {{ .Release.Name }} diff --git a/helm/chat-service-web-api/values.yaml b/helm/chat-service-web-api/values.yaml deleted file mode 100644 index d68d4fa..0000000 --- a/helm/chat-service-web-api/values.yaml +++ /dev/null @@ -1,69 +0,0 @@ -# Default values for chat-service-web-api. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 - -image: - repository: bhm7vnpxv6irqcr.azurecr.io/chatAPI - pullPolicy: Always - # Overrides the image tag whose default is the chart appVersion. - tag: latest - -service: - type: ClusterIP - port: 80 - -resources: {} - -nodeSelector: {} - -tolerations: [] - -affinity: {} - -ingress: - enabled: true - protocol: #http | https (set by script) - annotations: - kubernetes.io/ingress.class: addon-http-application-routing - ingress.kubernetes.io/ssl-redirect: "false" - nginx.ingress.kubernetes.io/ssl-redirect: "false" - ingress.kubernetes.io/rewrite-target: /$2 - nginx.ingress.kubernetes.io/rewrite-target: /$2 - tls: - - secretName: tls-prod - -env: - configmap: - - name: MSCosmosDBOpenAI__OpenAI__CompletionsDeployment - - name: MSCosmosDBOpenAI__OpenAI__CompletionsDeploymentMaxTokens - - name: MSCosmosDBOpenAI__OpenAI__EmbeddingsDeployment - - name: MSCosmosDBOpenAI__OpenAI__EmbeddingsDeploymentMaxTokens - - name: MSCosmosDBOpenAI__OpenAI__ChatCompletionPromptName - - name: MSCosmosDBOpenAI__OpenAI__ShortSummaryPromptName - - name: MSCosmosDBOpenAI__OpenAI__PromptOptimization__CompletionsMinTokens - - name: MSCosmosDBOpenAI__OpenAI__PromptOptimization__CompletionsMaxTokens - - name: MSCosmosDBOpenAI__OpenAI__PromptOptimization__SystemMaxTokens - - name: MSCosmosDBOpenAI__OpenAI__PromptOptimization__MemoryMinTokens - - name: MSCosmosDBOpenAI__OpenAI__PromptOptimization__MemoryMaxTokens - - name: MSCosmosDBOpenAI__OpenAI__PromptOptimization__MessagesMinTokens - - name: MSCosmosDBOpenAI__OpenAI__PromptOptimization__MessagesMaxTokens - - name: MSCosmosDBOpenAI__CosmosDB__Containers - - name: MSCosmosDBOpenAI__CosmosDB__MonitoredContainers - - name: MSCosmosDBOpenAI__CosmosDB__Database - - name: MSCosmosDBOpenAI__CosmosDB__ChangeFeedLeaseContainer - - name: MSCosmosDBOpenAI__DurableSystemPrompt__BlobStorageContainer - - name: MSCosmosDBOpenAI__BlobStorageMemorySource__ConfigBlobStorageContainer - - name: MSCosmosDBOpenAI__BlobStorageMemorySource__ConfigFilePath - secret: - - name: MSCosmosDBOpenAI__OpenAI__Endpoint - - name: MSCosmosDBOpenAI__OpenAI__Key - - name: MSCosmosDBOpenAI__CosmosDB__Endpoint - - name: MSCosmosDBOpenAI__CosmosDB__Key - - name: MSCosmosDBOpenAI__DurableSystemPrompt__BlobStorageConnection - - name: MSCosmosDBOpenAI__BlobStorageMemorySource__ConfigBlobStorageConnection - - name: ApplicationInsights__ConnectionString - values: - - name: ASPNETCORE_ENVIRONMENT - value: Production \ No newline at end of file diff --git a/helm/chat-web-app/.helmignore b/helm/chat-web-app/.helmignore deleted file mode 100644 index 0e8a0eb..0000000 --- a/helm/chat-web-app/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/helm/chat-web-app/Chart.yaml b/helm/chat-web-app/Chart.yaml deleted file mode 100644 index f062fdf..0000000 --- a/helm/chat-web-app/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -appVersion: "1.0" -description: A Helm chart for Kubernetes -name: chat-web-app -version: 0.1.0 diff --git a/helm/chat-web-app/templates/_helpers.tpl b/helm/chat-web-app/templates/_helpers.tpl deleted file mode 100644 index 8c76e42..0000000 --- a/helm/chat-web-app/templates/_helpers.tpl +++ /dev/null @@ -1,40 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "chat-web-app.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "chat-web-app.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "chat-web-app.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{- define "chat-web-app.apihost" -}} -{{- if .Values.apihost -}} -{{- printf "%s" .Values.apihost -}} -{{- else -}} -{{- printf "%s" (index .Values.ingress.hosts 0) -}} -{{- end -}} -{{- end -}} \ No newline at end of file diff --git a/helm/chat-web-app/templates/configmap.yaml b/helm/chat-web-app/templates/configmap.yaml deleted file mode 100644 index 1e56b4a..0000000 --- a/helm/chat-web-app/templates/configmap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -{{- $name := include "chat-web-app.fullname" . -}} -{{- $apihost := include "chat-web-app.apihost" . -}} - -apiVersion: v1 -kind: ConfigMap -metadata: - name: "cfg-{{ $name }}" - labels: - app: {{ template "chat-web-app.name" . }} - chart: {{ template "chat-web-app.chart" .}} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -data: - MSCosmosDBOpenAI__ChatManager__APIUrl: {{ .Values.apiUrl }} diff --git a/helm/chat-web-app/templates/deployment.yaml b/helm/chat-web-app/templates/deployment.yaml deleted file mode 100644 index abbfa45..0000000 --- a/helm/chat-web-app/templates/deployment.yaml +++ /dev/null @@ -1,73 +0,0 @@ -{{- $name := include "chat-web-app.fullname" . -}} -{{- $cfgname := printf "%s-%s" "cfg" $name -}} -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ template "chat-web-app.fullname" . }} - labels: - app: {{ template "chat-web-app.name" . }} - chart: {{ template "chat-web-app.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - app: {{ template "chat-web-app.name" . }} - release: {{ .Release.Name }} - template: - metadata: - annotations: - rollme: {{ randAlphaNum 5 | quote }} - labels: - app: {{ template "chat-web-app.name" . }} - release: {{ .Release.Name }} - spec: - {{ if .Values.serviceaccount -}} - serviceAccountName: {{ .Values.serviceaccount }} - {{ if .Values.imagePullSecrets -}} - imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} - {{- end }} - {{- end }} - containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - env: - {{- if .Values.env.values -}} - {{- range .Values.env.values }} - - name: {{ .name }} - value: {{ .value | quote }} - {{- end -}} - {{- end -}} - {{- if .Values.env.configmap -}} - {{- range .Values.env.configmap }} - - name: {{ .name }} - valueFrom: - configMapKeyRef: - name: {{ $cfgname }} - key: {{ .name }} - {{- end -}} - {{- end }} - ports: - - name: http - containerPort: 80 - protocol: TCP - resources: -{{ toYaml .Values.resources | indent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: -{{ toYaml . | indent 8 }} - {{- end }} - diff --git a/helm/chat-web-app/templates/ingress.yaml b/helm/chat-web-app/templates/ingress.yaml deleted file mode 100644 index 19e3fe2..0000000 --- a/helm/chat-web-app/templates/ingress.yaml +++ /dev/null @@ -1,41 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "chat-web-app.fullname" . -}} - -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app: {{ template "chat-web-app.name" . }} - chart: {{ template "chat-web-app.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: {{ $fullName }} - port: - number: 80 - {{- end }} -{{- end }} diff --git a/helm/chat-web-app/templates/secret.yaml b/helm/chat-web-app/templates/secret.yaml deleted file mode 100644 index 5d5552e..0000000 --- a/helm/chat-web-app/templates/secret.yaml +++ /dev/null @@ -1,14 +0,0 @@ -{{- $name := include "chat-web-app.fullname" . -}} - -apiVersion: v1 -kind: Secret -metadata: - name: "secret-{{ $name }}" - labels: - app: {{ template "chat-web-app.name" . }} - chart: {{ template "chat-web-app.chart" .}} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -type: Opaque -data: - ApplicationInsights__ConnectionString: {{ .Values.applicationInsights.connectionString | b64enc }} \ No newline at end of file diff --git a/helm/chat-web-app/templates/service.yaml b/helm/chat-web-app/templates/service.yaml deleted file mode 100644 index a240f3a..0000000 --- a/helm/chat-web-app/templates/service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ template "chat-web-app.fullname" . }} - labels: - app: {{ template "chat-web-app.name" . }} - chart: {{ template "chat-web-app.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - app: {{ template "chat-web-app.name" . }} - release: {{ .Release.Name }} diff --git a/helm/chat-web-app/values.yaml b/helm/chat-web-app/values.yaml deleted file mode 100644 index d8f692c..0000000 --- a/helm/chat-web-app/values.yaml +++ /dev/null @@ -1,47 +0,0 @@ -# Default values for chat-web-app. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 - -image: - repository: bhm7vnpxv6irqcr.azurecr.io/searchwebapp - pullPolicy: Always - # Overrides the image tag whose default is the chart appVersion. - tag: latest - -service: - type: ClusterIP - port: 80 - -resources: {} - -nodeSelector: {} - -tolerations: [] - -affinity: {} - -ingress: - enabled: true - protocol: #http | https (set by script) - annotations: - kubernetes.io/ingress.class: addon-http-application-routing - ingress.kubernetes.io/ssl-redirect: "false" - nginx.ingress.kubernetes.io/ssl-redirect: "false" - ingress.kubernetes.io/rewrite-target: / - nginx.ingress.kubernetes.io/rewrite-target: / - tls: - - secretName: tls-prod - -env: - configmap: - - name: MSCosmosDBOpenAI__ChatManager__APIUrl - secret: - - name: ApplicationInsights__ConnectionString - values: - - name: ASPNETCORE_ENVIRONMENT - value: Production - - name: MSCosmosDBOpenAI__ChatManager__APIRoutePrefix - value: /api - diff --git a/helm/tls-support/.helmignore b/helm/tls-support/.helmignore deleted file mode 100644 index f0c1319..0000000 --- a/helm/tls-support/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/helm/tls-support/Chart.yaml b/helm/tls-support/Chart.yaml deleted file mode 100644 index fd34955..0000000 --- a/helm/tls-support/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -appVersion: "1.0" -description: A Helm chart for Kubernetes -name: tls-support -version: 0.1.0 diff --git a/helm/tls-support/templates/_helpers.tpl b/helm/tls-support/templates/_helpers.tpl deleted file mode 100644 index 5088703..0000000 --- a/helm/tls-support/templates/_helpers.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "tt-tls.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "tt-tls.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "tt-tls.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/helm/tls-support/templates/certificate.yaml b/helm/tls-support/templates/certificate.yaml deleted file mode 100644 index 6e242d4..0000000 --- a/helm/tls-support/templates/certificate.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: cert-manager.io/v1 -kind: Certificate -metadata: - name: {{ .Values.certName }} - namespace: default - labels: - environment: {{ .Values.environment }} - app: {{ .Values.applicationName }} -spec: - secretName: {{ .Values.certSecretName }} - issuerRef: - name: {{ .Values.issuerName }} - commonName: {{ .Values.domain }} - dnsNames: - - {{ .Values.domain }} \ No newline at end of file diff --git a/helm/tls-support/templates/issuer.yaml b/helm/tls-support/templates/issuer.yaml deleted file mode 100644 index dd86261..0000000 --- a/helm/tls-support/templates/issuer.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: cert-manager.io/v1 -kind: Issuer -metadata: - name: {{ .Values.issuerName }} - namespace: default - labels: - environment: {{ .Values.environment }} - app: {{ .Values.applicationName }} -spec: - acme: - server: {{ .Values.server }} - email: not@used.com - privateKeySecretRef: - name: {{ .Values.issuerSecretName }} - solvers: - - http01: - ingress: - class: {{ .Values.ingressClass }} \ No newline at end of file diff --git a/helm/tls-support/values-prod.yaml b/helm/tls-support/values-prod.yaml deleted file mode 100644 index cfe37c8..0000000 --- a/helm/tls-support/values-prod.yaml +++ /dev/null @@ -1,8 +0,0 @@ -applicationName: ms-openai-cosmosdb-tls -issuerName: ms-openai-cosmosdb-tls-prod -certName: ms-openai-cosmosdb-tls-cert-prod -environment: prod -server: https://acme-v02.api.letsencrypt.org/directory -certSecretName: tls-prod -issuerSecretName: letsencrypt-prod -ingressClass: addon-http-application-routing \ No newline at end of file diff --git a/helm/tls-support/values-staging.yaml b/helm/tls-support/values-staging.yaml deleted file mode 100644 index 971057e..0000000 --- a/helm/tls-support/values-staging.yaml +++ /dev/null @@ -1,8 +0,0 @@ -applicationName: ms-openai-cosmosdb-tls -issuerName: ms-openai-cosmosdb-tls-staging -certName: ms-openai-cosmosdb-tls-cert-staging -environment: staging -server: https://acme-v02.api.letsencrypt.org/directory -certSecretName: tls-staging -issuerSecretName: letsencrypt-staging -ingressClass: addon-http-application-routing \ No newline at end of file diff --git a/migrationsettings.template.json b/migrationsettings.template.json deleted file mode 100644 index d1f3ffe..0000000 --- a/migrationsettings.template.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "Source": "JSON", - "Sink": "Cosmos-nosql", - "Operations": [ - { - "SourceSettings": { - "FilePath": "https://cosmosdbcosmicworks.blob.core.windows.net/cosmic-works-small/product.json" - }, - "SinkSettings": { - "ConnectionString": "{{cosmosConnectionString}}", - "Database":"vsai-database", - "Container":"product", - "PartitionKeyPath":"/categoryId", - "RecreateContainer": false, - "BatchSize": 100, - "ConnectionMode": "Direct", - "MaxRetryCount": 5, - "InitialRetryDurationMs": 200, - "UseAutoscaleForCreatedContainer": false, - "WriteMode": "InsertStream", - "IsServerlessAccount": true - } - }, - { - "SourceSettings": { - "FilePath": "https://cosmosdbcosmicworks.blob.core.windows.net/cosmic-works-small/customer.json" - }, - "SinkSettings": { - "ConnectionString": "{{cosmosConnectionString}}", - "Database":"vsai-database", - "Container":"customer", - "PartitionKeyPath":"/customerId", - "RecreateContainer": false, - "BatchSize": 100, - "ConnectionMode": "Direct", - "MaxRetryCount": 5, - "InitialRetryDurationMs": 200, - "UseAutoscaleForCreatedContainer": false, - "WriteMode": "InsertStream", - "IsServerlessAccount": true - } - } - ] -} diff --git a/scripts/BuildPush.ps1 b/scripts/BuildPush.ps1 deleted file mode 100644 index 3431911..0000000 --- a/scripts/BuildPush.ps1 +++ /dev/null @@ -1,52 +0,0 @@ -#! /usr/bin/pwsh - -Param( - [parameter(Mandatory=$true)][string]$resourceGroup, - [parameter(Mandatory=$true)][string]$acrName, - [parameter(Mandatory=$false)][bool]$dockerBuild=$true, - [parameter(Mandatory=$false)][bool]$dockerPush=$true, - [parameter(Mandatory=$false)][string]$dockerTag="latest", - [parameter(Mandatory=$false)][bool]$isWindowsMachine=$false -) - -Push-Location $($MyInvocation.InvocationName | Split-Path) -$sourceFolder=$(./Join-Path-Recursively.ps1 -pathParts ..,scripts) -Write-Host "---------------------------------------------------" -ForegroundColor Yellow - -Write-Host "---------------------------------------------------" -ForegroundColor Yellow -Write-Host "Getting info from ACR $resourceGroup/$acrName" -ForegroundColor Yellow -Write-Host "---------------------------------------------------" -ForegroundColor Yellow -$acrLoginServer=$(az acr show -g $resourceGroup -n $acrName -o json | ConvertFrom-Json).loginServer -$acrCredentials=$(az acr credential show -g $resourceGroup -n $acrName -o json | ConvertFrom-Json) -$acrPwd=$acrCredentials.passwords[0].value -$acrUser=$acrCredentials.username -$dockerComposeFile="../docker/docker-compose.yml" - - -if ($dockerBuild) { - Write-Host "---------------------------------------------------" -ForegroundColor Yellow - Write-Host "Using docker compose to build & tag images." -ForegroundColor Yellow - Write-Host "Images will be named as $acrLoginServer/imageName:$dockerTag" -ForegroundColor Yellow - Write-Host "---------------------------------------------------" -ForegroundColor Yellow - - Push-Location $sourceFolder - $env:TAG=$dockerTag - $env:REGISTRY=$acrLoginServer - docker-compose -f $dockerComposeFile build - Pop-Location -} - -if ($dockerPush) { - Write-Host "---------------------------------------------------" -ForegroundColor Yellow - Write-Host "Pushing images to $acrLoginServer" -ForegroundColor Yellow - Write-Host "---------------------------------------------------" -ForegroundColor Yellow - - Push-Location $sourceFolder - docker login -p $acrPwd -u $acrUser $acrLoginServer - $env:TAG=$dockerTag - $env:REGISTRY=$acrLoginServer - docker-compose -f $dockerComposeFile push - Pop-Location -} - -Pop-Location \ No newline at end of file diff --git a/scripts/CloudShell-Deploy.ps1 b/scripts/CloudShell-Deploy.ps1 deleted file mode 100644 index f4c4bbf..0000000 --- a/scripts/CloudShell-Deploy.ps1 +++ /dev/null @@ -1,102 +0,0 @@ -#! /usr/bin/pwsh - -Param( - [parameter(Mandatory=$false)][string]$acrName="bydtochatgptcr", - [parameter(Mandatory=$false)][string]$acrResourceGroup="ms-byd-to-chatgpt", - [parameter(Mandatory=$true)][string]$resourceGroup, - [parameter(Mandatory=$true)][string]$location, - [parameter(Mandatory=$true)][string]$subscription, - [parameter(Mandatory=$false)][string]$armTemplate="azuredeploy.json", - [parameter(Mandatory=$false)][bool]$stepDeployArm=$true, - [parameter(Mandatory=$false)][bool]$stepDeployCertManager=$true, - [parameter(Mandatory=$false)][bool]$stepDeployTls=$true, - [parameter(Mandatory=$false)][bool]$stepDeployImages=$true, - [parameter(Mandatory=$false)][bool]$stepUploadSystemPrompts=$true, - [parameter(Mandatory=$false)][bool]$stepImportData=$true, - [parameter(Mandatory=$false)][bool]$stepLoginAzure=$false -) - -$gValuesFile="configFile.yaml" - -Push-Location $($MyInvocation.InvocationName | Split-Path) - -# Update the extension to make sure you have the latest version installed -az extension add --name aks-preview -az extension update --name aks-preview - -az extension add --name application-insights -az extension update --name application-insights - -az extension add --name storage-preview -az extension update --name storage-preview - -if ($stepLoginAzure) { - # Write-Host "Login in your account" -ForegroundColor Yellow - az login -} - -# Write-Host "Choosing your subscription" -ForegroundColor Yellow -az account set --subscription $subscription - -if ($stepDeployArm) { - # Deploy ARM - & ./Deploy-Arm-Azure.ps1 -resourceGroup $resourceGroup -location $location -template $armTemplate -resourcePrefix $resourcePrefix -cosmosDbAccountName $cosmosDbAccountName -} - -# Connecting kubectl to AKS -Write-Host "Retrieving Aks Name" -ForegroundColor Yellow -$aksName = $(az aks list -g $resourceGroup -o json | ConvertFrom-Json).name -Write-Host "The name of your AKS: $aksName" -ForegroundColor Yellow - -# Write-Host "Retrieving credentials" -ForegroundColor Yellow -az aks get-credentials -n $aksName -g $resourceGroup --overwrite-existing - -# Generate Config -New-Item -ItemType Directory -Force -Path $(./Join-Path-Recursively.ps1 -pathParts ..,__values) -$gValuesLocation=$(./Join-Path-Recursively.ps1 -pathParts ..,__values,$gValuesFile) -& ./Generate-Config.ps1 -resourceGroup $resourceGroup -outputFile $gValuesLocation - -# Create Secrets -if ([string]::IsNullOrEmpty($acrName)) -{ - $acrName = $(az acr list --resource-group $resourceGroup -o json | ConvertFrom-Json).name - $acrResourceGroup = $resourceGroup -} - -Write-Host "The Name of your ACR: $acrName" -ForegroundColor Yellow -# & ./Create-Secret.ps1 -resourceGroup $resourceGroup -acrName $acrName -# az aks update -n $aksName -g $resourceGroup --attach-acr $acrName - -if ($stepDeployCertManager) { - # Deploy Cert Manager - & ./DeployCertManager.ps1 -} - -if ($stepDeployTls) { - # Deploy TLS - & ./DeployTlsSupport.ps1 -sslSupport prod -resourceGroup $resourceGroup -aksName $aksName -} - -if ($stepUploadSystemPrompts) { - # Upload System Prompts - & ./UploadSystemPrompts.ps1 -resourceGroup $resourceGroup -location $location -} - -if ($stepDeployImages) { - # Deploy images in AKS - $gValuesLocation=$(./Join-Path-Recursively.ps1 -pathParts ..,__values,$gValuesFile) - $chartsToDeploy = "*" - & ./Deploy-Images-Aks.ps1 -aksName $aksName -resourceGroup $resourceGroup -charts $chartsToDeploy -acrName $acrName -acrResourceGroup $acrResourceGroup -valuesFile $gValuesLocation -} - -if ($stepImportData) { - # Import Data - & ./Import-Data-CloudShell.ps1 -resourceGroup $resourceGroup -aksName $aksName -} - -$webappHostname=$(az aks show -n $aksName -g $resourceGroup -o json --query addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName | ConvertFrom-Json) -Write-Host "===========================================================" -ForegroundColor Yellow -Write-Host "The frontend is hosted at https://$webappHostname" -ForegroundColor Yellow -Write-Host "===========================================================" -ForegroundColor Yellow - -Pop-Location diff --git a/scripts/Deploy-Arm-Azure.ps1 b/scripts/Deploy-Arm-Azure.ps1 deleted file mode 100644 index ec3c4b7..0000000 --- a/scripts/Deploy-Arm-Azure.ps1 +++ /dev/null @@ -1,62 +0,0 @@ -#! /usr/bin/pwsh - -Param( - [parameter(Mandatory=$true)][string]$resourceGroup, - [parameter(Mandatory=$true)][string]$location, - [parameter(Mandatory=$false)][string]$template="azuredeploy.json", - [parameter(Mandatory=$false)][string]$resourcePrefix, - [parameter(Mandatory=$false)][string]$cosmosDbAccountName, - [parameter(Mandatory=$false)][bool]$deployAks, - [parameter(Mandatory=$true)][string]$openAiEndpoint, - [parameter(Mandatory=$true)][string]$openAiKey, - [parameter(Mandatory=$true)][string]$openAiCompletionsDeployment, - [parameter(Mandatory=$true)][string]$openAiEmbeddingsDeployment -) - -$sourceFolder=$(Join-Path -Path .. -ChildPath arm) - -Push-Location $($MyInvocation.InvocationName | Split-Path) - -$script=$template - -Write-Host "--------------------------------------------------------" -ForegroundColor Yellow -Write-Host "Deploying ARM script $script" -ForegroundColor Yellow -Write-Host "-------------------------------------------------------- " -ForegroundColor Yellow - -$rg = $(az group list --query "[?name=='$resourceGroup']" -o json | ConvertFrom-Json) -# Deployment without AKS can be done in a existing or non-existing resource group. -if ($rg.length -eq 0) { - Write-Host "Creating resource group $resourceGroup in $location" -ForegroundColor Yellow - az group create -n $resourceGroup -l $location -} - -# TODO: Uncomment this when AZ CLI consistently returns a valid semantic version for AKS -# Write-Host "Getting last AKS version in location $location" -ForegroundColor Yellow -# $aksVersions=$(az aks get-versions -l $location --query values[].version -o json | ConvertFrom-Json) -# $aksLastVersion=$aksVersions[$aksVersions.Length-1] -# Write-Host "AKS last version is $aksLastVersion" -ForegroundColor Yellow -$aksLastVersion="1.27.3" - -$deploymentName = "cosmosdb-openai-azuredeploy" - -Write-Host "Begining the ARM deployment..." -ForegroundColor Yellow -Push-Location $sourceFolder -if ($deployAks) -{ - az deployment group create -g $resourceGroup -n $deploymentName --template-file $script --parameters k8sVersion=$aksLastVersion -} -else -{ - az deployment group create -g $resourceGroup -n $deploymentName --template-file $script --parameters openAiEndpoint=$openAiEndpoint --parameters openAiKey=$openAiKey --parameters openAiCompletionsDeployment=$openAiCompletionsDeployment --parameters openAiEmbeddingsDeployment=$openAiEmbeddingsDeployment -} - -$outputVal = (az deployment group show -g $resourceGroup -n $deploymentName --query properties.outputs.resourcePrefix.value) | ConvertFrom-Json -Set-Variable -Name resourcePrefix -Value $outputVal.ToString() -Scope 1 -Write-Host "The resource prefix used in deployment is $outputVal" - -$outputVal = (az deployment group show -g $resourceGroup -n $deploymentName --query properties.outputs.cosmosDbAccountName.value) | ConvertFrom-Json -Set-Variable -Name cosmosDbAccountName -Value $outputVal.ToString() -Scope 1 -Write-Host "The CosmosDB account name used in deployment is $outputVal" - -Pop-Location -Pop-Location diff --git a/scripts/Deploy-Images-Aca.ps1 b/scripts/Deploy-Images-Aca.ps1 deleted file mode 100644 index 5720fc2..0000000 --- a/scripts/Deploy-Images-Aca.ps1 +++ /dev/null @@ -1,87 +0,0 @@ -#! /usr/bin/pwsh - -Param( - [parameter(Mandatory=$false)][string]$name = "ms-openai-cosmos-db", - [parameter(Mandatory=$false)][string]$resourceGroup, - [parameter(Mandatory=$false)][string]$acrName, - [parameter(Mandatory=$false)][string]$acrResourceGroup=$resourceGroup, - [parameter(Mandatory=$false)][string]$tag="latest" -) - -function validate { - $valid = $true - - if ([string]::IsNullOrEmpty($resourceGroup)) { - Write-Host "No resource group. Use -resourceGroup to specify resource group." -ForegroundColor Red - $valid=$false - } - - if ([string]::IsNullOrEmpty($acrLogin)) { - Write-Host "ACR login server can't be found. Are you using right ACR ($acrName) and RG ($resourceGroup)?" -ForegroundColor Red - $valid=$false - } - - if ($valid -eq $false) { - exit 1 - } -} - -Write-Host "--------------------------------------------------------" -ForegroundColor Yellow -Write-Host " Deploying images on Aca" -ForegroundColor Yellow -Write-Host " " -ForegroundColor Yellow -Write-Host " Additional parameters are:" -ForegroundColor Yellow -Write-Host " Images tag: $tag" -ForegroundColor Yellow -Write-Host " --------------------------------------------------------" - -if ($acrName -ne "bydtochatgptcr") { - $acrLogin=$(az acr show -n $acrName -g $acrResourceGroup -o json| ConvertFrom-Json).loginServer - Write-Host "acr login server is $acrLogin" -ForegroundColor Yellow -} -else { - $acrLogin="bydtochatgptcr.azurecr.io" -} - -$deploymentOutputs=$(az deployment group show -g $resourceGroup -n cosmosdb-openai-azuredeploy -o json --query properties.outputs | ConvertFrom-Json) - -validate - -Push-Location $($MyInvocation.InvocationName | Split-Path) - -Write-Host "Deploying images..." -ForegroundColor Yellow - -Write-Host "API deployment - api" -ForegroundColor Yellow -$command = "az containerapp update --name $($deploymentOutputs.apiAcaName.value) --resource-group $resourceGroup --image $acrLogin/chat-service-api:$tag" -Invoke-Expression "$command" - -Write-Host "Webapp deployment - web" -ForegroundColor Yellow -$command = "az containerapp update --name $($deploymentOutputs.webAcaName.value) --resource-group $resourceGroup --image $acrLogin/chat-web-app:$tag" -Invoke-Expression "$command" - -Write-Host " --------------------------------------------------------" -Write-Host "Entering holding pattern to wait for proper backend API initialization" -Write-Host "Attempting to retrieve status from https://$($deploymentOutputs.apiFqdn.value)/status every 20 seconds with 50 retries" -Write-Host " --------------------------------------------------------" -$apiStatus = "initializing" -$retriesLeft = 50 -while (($apiStatus.ToString() -ne "ready") -and ($retriesLeft -gt 0)) { - Start-Sleep -Seconds 20 - try { - $apiStatus = Invoke-RestMethod -Uri "https://$($deploymentOutputs.apiFqdn.value)/status" -Method GET - } - catch { - Write-Host "The attempt to invoke the API endpoint failed. Will retry." - } - finally { - Write-Host "Last known API endpoint status: $($apiStatus)" - } - - $retriesLeft -= 1 -} - -if ($apiStatus.ToString() -ne "ready") { - throw "The backend API did not enter the ready state." -} - -Pop-Location - -Write-Host "MS OpenAI Chat deployed to ACA" -ForegroundColor Yellow \ No newline at end of file diff --git a/scripts/Deploy-Images-Aks.ps1 b/scripts/Deploy-Images-Aks.ps1 deleted file mode 100644 index 8d98662..0000000 --- a/scripts/Deploy-Images-Aks.ps1 +++ /dev/null @@ -1,168 +0,0 @@ -#! /usr/bin/pwsh - -Param( - [parameter(Mandatory=$false)][string]$name = "ms-openai-cosmos-db", - [parameter(Mandatory=$false)][string]$aksName, - [parameter(Mandatory=$false)][string]$resourceGroup, - [parameter(Mandatory=$false)][string]$acrName, - [parameter(Mandatory=$false)][string]$acrResourceGroup=$resourceGroup, - [parameter(Mandatory=$false)][string]$tag="latest", - [parameter(Mandatory=$false)][string]$charts = "*", - [parameter(Mandatory=$false)][string]$valuesFile = "", - [parameter(Mandatory=$false)][string]$namespace = "", - [parameter(Mandatory=$false)][string][ValidateSet('prod','staging','none','custom', IgnoreCase=$false)]$tlsEnv = "prod", - [parameter(Mandatory=$false)][string]$tlsHost="", - [parameter(Mandatory=$false)][string]$tlsSecretName="tls-prod", - [parameter(Mandatory=$false)][bool]$autoscale=$false -) - -function validate { - $valid = $true - - if ([string]::IsNullOrEmpty($aksName)) { - Write-Host "No AKS name. Use -aksName to specify name" -ForegroundColor Red - $valid=$false - } - if ([string]::IsNullOrEmpty($resourceGroup)) { - Write-Host "No resource group. Use -resourceGroup to specify resource group." -ForegroundColor Red - $valid=$false - } - - if ([string]::IsNullOrEmpty($aksHost) -and $tlsEnv -ne "custom") { - Write-Host "AKS host of HttpRouting can't be found. Are you using right AKS ($aksName) and RG ($resourceGroup)?" -ForegroundColor Red - $valid=$false - } - if ([string]::IsNullOrEmpty($acrLogin)) { - Write-Host "ACR login server can't be found. Are you using right ACR ($acrName) and RG ($resourceGroup)?" -ForegroundColor Red - $valid=$false - } - - if ($tlsEnv -eq "custom" -and [string]::IsNullOrEmpty($tlsSecretName)) { - Write-Host "If tlsEnv is custom must use -tlsSecretName to set the TLS secret name (you need to install this secret manually)" - $valid=$false - } - - if ($tlsEnv -eq "custom" -and [string]::IsNullOrEmpty($tlsHost)) { - Write-Host "If tlsEnv is custom must use -tlsHost to set the hostname of AKS (inferred name of Http Application Routing won't be used)" - $valid=$false - } - - if ($valid -eq $false) { - exit 1 - } -} - -function createHelmCommand([string]$command) { - $tlsSecretNameToUse = "" - if ($tlsEnv -eq "staging") { - $tlsSecretNameToUse = "tls-staging" - } - if ($tlsEnv -eq "prod") { - $tlsSecretNameToUse = "tls-prod" - } - if ($tlsEnv -eq "custom") { - $tlsSecretNameToUse=$tlsSecretName - } - - $newcommand = $command - - if (-not [string]::IsNullOrEmpty($namespace)) { - $newcommand = "$newcommand --namespace $namespace" - } - - if (-not [string]::IsNullOrEmpty($tlsSecretNameToUse)) { - $newcommand = "$newcommand --set ingress.tls[0].secretName=$tlsSecretNameToUse --set ingress.tls[0].hosts='{$aksHost}'" - } - - return "$newcommand"; -} - -Write-Host "--------------------------------------------------------" -ForegroundColor Yellow -Write-Host " Deploying images on cluster $aksName" -ForegroundColor Yellow -Write-Host " " -ForegroundColor Yellow -Write-Host " Additional parameters are:" -ForegroundColor Yellow -Write-Host " Release Name: $name" -ForegroundColor Yellow -Write-Host " AKS to use: $aksName in RG $resourceGroup and ACR $acrName" -ForegroundColor Yellow -Write-Host " Images tag: $tag" -ForegroundColor Yellow -Write-Host " TLS/SSL environment to enable: $tlsEnv" -ForegroundColor Yellow -Write-Host " Namespace (empty means the one in .kube/config): $namespace" -ForegroundColor Yellow -Write-Host " --------------------------------------------------------" - -if ($acrName -ne "bydtochatgptcr") { - $acrLogin=$(az acr show -n $acrName -g $acrResourceGroup -o json| ConvertFrom-Json).loginServer - Write-Host "acr login server is $acrLogin" -ForegroundColor Yellow -} -else { - $acrLogin="bydtochatgptcr.azurecr.io" -} - -if ($tlsEnv -ne "custom" -and [String]::IsNullOrEmpty($tlsHost)) { - $aksHost=$(az aks show -n $aksName -g $resourceGroup --query addonProfiles.httpapplicationrouting.config.HTTPApplicationRoutingZoneName -o json | ConvertFrom-Json) - - if (-not $aksHost) { - $aksHost=$(az aks show -n $aksName -g $resourceGroup --query addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName -o json | ConvertFrom-Json) - } - - Write-Host "acr login server is $acrLogin" -ForegroundColor Yellow - Write-Host "aksHost is $aksHost" -ForegroundColor Yellow -} -else { - $aksHost=$tlsHost -} - -validate - -Push-Location $($MyInvocation.InvocationName | Split-Path) -Push-Location $(Join-Path .. helm) - -Write-Host "Deploying charts $charts" -ForegroundColor Yellow - -if ([String]::IsNullOrEmpty($valuesFile)) { - $valuesFile="gvalues.yaml" -} - -Write-Host "Configuration file used is $valuesFile" -ForegroundColor Yellow - -if ($charts.Contains("api") -or $charts.Contains("*")) { - Write-Host "API chart - api" -ForegroundColor Yellow - $command = "helm upgrade --install $name-api ./chat-service-web-api -f $valuesFile --set ingress.hosts='{$aksHost}' --set image.repository=$acrLogin/chat-service-api --set image.tag=$tag --set hpa.activated=$autoscale" - $command = createHelmCommand $command - Invoke-Expression "$command" -} - -if ($charts.Contains("web") -or $charts.Contains("*")) { - Write-Host "Webapp chart - web" -ForegroundColor Yellow - $command = "helm upgrade --install $name-web ./chat-web-app -f $valuesFile --set ingress.hosts='{$aksHost}' --set image.repository=$acrLogin/chat-web-app --set image.tag=$tag --set hpa.activated=$autoscale" - $command = createHelmCommand $command - Invoke-Expression "$command" -} - -Write-Host " --------------------------------------------------------" -Write-Host "Entering holding pattern to wait for proper backend API initialization" -Write-Host "Attempting to retrieve status from https://$($aksHost)/api/status every 20 seconds with 50 retries" -Write-Host " --------------------------------------------------------" -$apiStatus = "initializing" -$retriesLeft = 50 -while (($apiStatus.ToString() -ne "ready") -and ($retriesLeft -gt 0)) { - Start-Sleep -Seconds 20 - try { - $apiStatus = Invoke-RestMethod -Uri "https://$($aksHost)/api/status" -Method GET - } - catch { - Write-Host "The attempt to invoke the API endpoint failed. Will retry." - } - finally { - Write-Host "Last known API endpoint status: $($apiStatus)" - } - - $retriesLeft -= 1 -} - -if ($apiStatus.ToString() -ne "ready") { - throw "The backend API did not enter the ready state." -} - -Pop-Location -Pop-Location - -Write-Host "MS OpenAI Chat deployed on AKS" -ForegroundColor Yellow \ No newline at end of file diff --git a/scripts/Deploy-OpenAi.ps1 b/scripts/Deploy-OpenAi.ps1 deleted file mode 100644 index 59cf4ba..0000000 --- a/scripts/Deploy-OpenAi.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/pwsh - -Param( - [parameter(Mandatory=$true)][string]$name, - [parameter(Mandatory=$true)][string]$resourceGroup, - [parameter(Mandatory=$true)][string]$location, - [parameter(Mandatory=$true)][string]$completionsDeployment, - [parameter(Mandatory=$true)][string]$embeddingsDeployment -) - -Push-Location $($MyInvocation.InvocationName | Split-Path) - -if (-Not (az cognitiveservices account list -g $resourceGroup --query '[].name' -o json | ConvertFrom-Json) -Contains $name) { - Write-Host("The Azure OpenAI account $($name) was not found, creating it...") - az cognitiveservices account create -g $resourceGroup -n $name --kind OpenAI --sku S0 --location $location --yes --custom-domain $name -} - -$deployments = (az cognitiveservices account deployment list -g $resourceGroup -n $name --query '[].name' -o json | ConvertFrom-Json) -Write-Host "Existing deployments: $($deployments)" -if (-Not ($deployments -Contains $completionsDeployment)) { - Write-Host("The Azure OpenAI deployment $($completionsDeployment) under account $($name) was not found, creating it...") - az cognitiveservices account deployment create -g $resourceGroup -n $name --deployment-name $completionsDeployment --model-name 'gpt-35-turbo' --model-version '0301' --model-format OpenAI --sku Standard --sku-capacity 120 -} - -$deployments = (az cognitiveservices account deployment list -g $resourceGroup -n $name --query '[].name' -o json | ConvertFrom-Json) -Write-Host "Existing deployments: $($deployments)" -if (-Not ($deployments -Contains $embeddingsDeployment)) { - Write-Host("The Azure OpenAI deployment $($embeddingsDeployment) under account $($name) was not found, creating it...") - az cognitiveservices account deployment create -g $resourceGroup -n $name --deployment-name $embeddingsDeployment --model-name 'text-embedding-ada-002' --model-version '2' --model-format OpenAI --sku Standard --sku-capacity 120 -} - -Pop-Location \ No newline at end of file diff --git a/scripts/Deploy-Vm.ps1 b/scripts/Deploy-Vm.ps1 deleted file mode 100644 index 6f10362..0000000 --- a/scripts/Deploy-Vm.ps1 +++ /dev/null @@ -1,47 +0,0 @@ -#! /usr/bin/pwsh - -Param( - [parameter(Mandatory=$true)][string]$resourceGroup, - [parameter(Mandatory=$true)][string]$location, - [parameter(Mandatory=$true)][string]$password, - [parameter(Mandatory=$false)][string]$template="vmdeploy.json" -) - -$sourceFolder=$(Join-Path -Path .. -ChildPath arm) - -Push-Location $($MyInvocation.InvocationName | Split-Path) - -$script=$template - -Write-Host "--------------------------------------------------------" -ForegroundColor Yellow -Write-Host "Deploying ARM script $script" -ForegroundColor Yellow -Write-Host "-------------------------------------------------------- " -ForegroundColor Yellow - -$rg = $(az group list --query "[?name=='$resourceGroup']" -o json | ConvertFrom-Json) -# Deployment without AKS can be done in a existing or non-existing resource group. -if ($rg.length -eq 0) { - Write-Host "Creating resource group $resourceGroup in $location" -ForegroundColor Yellow - az group create -n $resourceGroup -l $location -} - -# TODO: Uncomment this when AZ CLI consistently returns a valid semantic version for AKS -# Write-Host "Getting last AKS version in location $location" -ForegroundColor Yellow -# $aksVersions=$(az aks get-versions -l $location --query values[].version -o json | ConvertFrom-Json) -# $aksLastVersion=$aksVersions[$aksVersions.Length-1] -# Write-Host "AKS last version is $aksLastVersion" -ForegroundColor Yellow -$aksLastVersion="1.27.3" - -$deploymentName = "cosmosdb-openai-vmdeploy" - -Write-Host "Begining the ARM deployment..." -ForegroundColor Yellow -Push-Location $sourceFolder -az deployment group create -g $resourceGroup -n $deploymentName --template-file $script --parameters location=$($location.ToLower()) password=$password - -$outputVal = (az deployment group show -g $resourceGroup -n $deploymentName --query properties.outputs.resourcePrefix.value) | ConvertFrom-Json -Write-Host "The resource prefix used in deployment is $outputVal" - -$outputVal = (az deployment group show -g $resourceGroup -n $deploymentName --query properties.outputs.deployedVM.value) | ConvertFrom-Json -Write-Host "The deployed VM name used in deployment is $outputVal" - -Pop-Location -Pop-Location diff --git a/scripts/DeployCertManager.ps1 b/scripts/DeployCertManager.ps1 deleted file mode 100644 index 69c46ce..0000000 --- a/scripts/DeployCertManager.ps1 +++ /dev/null @@ -1,8 +0,0 @@ -#! /usr/bin/pwsh - -# Adds the official cert-manager repository to your local and updates the repo cache -Invoke-Expression "helm repo add jetstack https://charts.jetstack.io" -Invoke-Expression "helm repo update" - -# Installs cert-manager on cluster -Invoke-Expression "helm upgrade --install cert-manager jetstack/cert-manager --namespace kube-system --version v1.9.1 --set installCRDs=true" \ No newline at end of file diff --git a/scripts/DeployTlsSupport.ps1 b/scripts/DeployTlsSupport.ps1 deleted file mode 100644 index 214899c..0000000 --- a/scripts/DeployTlsSupport.ps1 +++ /dev/null @@ -1,95 +0,0 @@ -#! /usr/bin/pwsh - -Param ( - [parameter(Mandatory=$false)][string][ValidateSet('prod','staging','none','custom', IgnoreCase=$false)]$sslSupport = "none", - [parameter(Mandatory=$false)][string]$name = "ms-openai-cosmosdb", - [parameter(Mandatory=$false)][string]$aksName, - [parameter(Mandatory=$false)][string]$resourceGroup, - [parameter(Mandatory=$false)][string]$tlsCertFile="", - [parameter(Mandatory=$false)][string]$tlsKeyFile="", - [parameter(Mandatory=$false)][string]$domain="", - [parameter(Mandatory=$false)][string]$tlsSecretName="tls-prod", - [parameter(Mandatory=$false)][string]$ingressClass="addon-http-application-routing" -) - -function validate { - $valid = $true - - if ([string]::IsNullOrEmpty($aksName)) { - Write-Host "No AKS name. Use -aksName to specify name" -ForegroundColor Red - $valid=$false - } - if ([string]::IsNullOrEmpty($resourceGroup)) { - Write-Host "No resource group. Use -resourceGroup to specify resource group." -ForegroundColor Red - $valid=$false - } - - if ($sslSupport -eq "custom") { - if ([string]::IsNullOrEmpty($domain)) { - Write-Host "If sslSupport is 'custom' the domain parameter is mandatory." -ForegroundColor Red - $valid=$false - } - if ([String]::IsNullOrEmpty($tlsCertFile)) { - Write-Host "If sslSupport is 'custom' then need to pass the certificate file in tlsCertFile parameter" -ForegroundColor Red - $valid=$false - } - if ([String]::IsNullOrEmpty($tlsKeyFile)) { - Write-Host "If sslSupport is 'custom' then need to pass the certificate key file in tlsKeyFile parameter" -ForegroundColor Red - $valid=$false - } - if ([String]::IsNullOrEmpty($tlsSecretName)) { - Write-Host "If sslSupport is 'custom' then need to pass the Kubernetes secret name in tlsSecretName parameter" -ForegroundColor Red - $valid=$false - } - } - - if ($sslSupport -eq "none") { - Write-Host "sslSupport set to none. Nothing will be done. Use staging or prod to setup SSL/TLS" -ForegroundColor Yellow - $valid=$false - } - - if ($valid -eq $false) { - exit 1 - } -} - -validate - -Write-Host "--------------------------------------------------------" -ForegroundColor Yellow -Write-Host " Enabling SSL/TLS support on cluster $aksName in RG $resourceGroup" -ForegroundColor Yellow -Write-Host " --------------------------------------------------------" -ForegroundColor Yellow - -if ([String]::IsNullOrEmpty($domain)) { - $domain = $(az aks show -n $aksName -g $resourceGroup -o json --query addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName | ConvertFrom-Json) - if (-not $domain) { - $domain = $(az aks show -n $aksName -g $resourceGroup -o json --query addonProfiles.httpapplicationrouting.config.HTTPApplicationRoutingZoneName | ConvertFrom-Json) - } -} - -if ([String]::IsNullOrEmpty($domain)) { - Write-Host "Error: domain not passed and can't be inferred from AKS $aksName" -ForegroundColor Red - exit 1 -} - -Write-Host "TLS/SSL will be bound to domain $domain" -Join-Path .. helm | Push-Location - -if ($sslSupport -eq "staging") { - Write-Host "Adding TLS/SSL support using Let's Encrypt Staging environment" -ForegroundColor Yellow - $command = "helm upgrade --install $name-ssl-staging tls-support -f $(Join-Path tls-support values-staging.yaml) --set domain=$domain --set ingressClass=$ingressClass" - Invoke-Expression "$command" -} -if ($sslSupport -eq "prod") { - Write-Host "Adding TLS/SSL support using Let's Encrypt PRODUCTION environment" -ForegroundColor Yellow - Write-Host "helm upgrade --install $name-ssl-prod tls-support -f $(Join-Path tls-support values-prod.yaml) --set domain=$domain --set ingressClass=$ingressClass" - $command = "helm upgrade --install $name-ssl-prod tls-support -f $(Join-Path tls-support values-prod.yaml) --set domain=$domain --set ingressClass=$ingressClass" - Invoke-Expression "$command" -} -if ($sslSupport -eq "custom") { - Write-Host "TLS support is custom bound to domain $domain" -ForegroundColor Yellow - Write-Host "Creating secret $tlsSecretName with TLS certificate from file $tlsCertFile and key from $tlsKeyFile" - $command = "kubectl create secret tls $tlsSecretName --key $tlsKeyFile --cert $tlsCertFile" - Invoke-Expression "$command" -} - -Pop-Location \ No newline at end of file diff --git a/scripts/Generate-Config.ps1 b/scripts/Generate-Config.ps1 deleted file mode 100644 index 61e6391..0000000 --- a/scripts/Generate-Config.ps1 +++ /dev/null @@ -1,121 +0,0 @@ -#! /usr/bin/pwsh - -Param ( - [parameter(Mandatory=$true)][string]$resourceGroup, - [parameter(Mandatory=$false)][string]$openAiName, - [parameter(Mandatory=$false)][string]$openAiRg, - [parameter(Mandatory=$false)][string]$openAiDeployment, - [parameter(Mandatory=$false)][string[]]$outputFile=$null, - [parameter(Mandatory=$false)][string[]]$gvaluesTemplate="..,gvalues.template.yml", - [parameter(Mandatory=$false)][string[]]$migrationSettingsTemplate="..,migrationsettings.template.json", - [parameter(Mandatory=$false)][string]$ingressClass="addon-http-application-routing", - [parameter(Mandatory=$false)][string]$domain -) - -function EnsureAndReturnFirstItem($arr, $restype) { - if (-not $arr -or $arr.Length -ne 1) { - Write-Host "Fatal: No $restype found (or found more than one)" -ForegroundColor Red - exit 1 - } - - return $arr[0] -} - -# Check the rg -$rg=$(az group show -n $resourceGroup -o json | ConvertFrom-Json) - -if (-not $rg) { - Write-Host "Fatal: Resource group not found" -ForegroundColor Red - exit 1 -} - -### Getting Resources -$tokens=@{} - -## Getting storage info -# $storage=$(az storage account list -g $resourceGroup --query "[].{name: name, blob: primaryEndpoints.blob}" -o json | ConvertFrom-Json) -# $storage=EnsureAndReturnFirstItem $storage "Storage Account" -# Write-Host "Storage Account: $($storage.name)" -ForegroundColor Yellow - -## Getting API URL domain -if ([String]::IsNullOrEmpty($domain)) { - $domain = $(az aks show -n $aksName -g $resourceGroup -o json --query addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName | ConvertFrom-Json) - if (-not $domain) { - $domain = $(az aks show -n $aksName -g $resourceGroup -o json --query addonProfiles.httpapplicationrouting.config.HTTPApplicationRoutingZoneName | ConvertFrom-Json) - } -} - -$apiUrl = "https://$domain" - -## Getting CosmosDb info -$docdb=$(az cosmosdb list -g $resourceGroup --query "[?kind=='GlobalDocumentDB'].{name: name, kind:kind, documentEndpoint:documentEndpoint}" -o json | ConvertFrom-Json) -$docdb=EnsureAndReturnFirstItem $docdb "CosmosDB (Document Db)" -$docdbKey=$(az cosmosdb keys list -g $resourceGroup -n $docdb.name -o json --query primaryMasterKey | ConvertFrom-Json) -Write-Host "Document Db Account: $($docdb.name)" -ForegroundColor Yellow - -## Getting Storage info -$blobAccount=$(az storage account list -g $resourceGroup -o json | ConvertFrom-Json).name -$blobKey=$(az storage account keys list -g $resourceGroup -n $blobAccount -o json | ConvertFrom-Json)[0].value - -## Getting OpenAI info -if ($openAiName) { - $openAi=$(az cognitiveservices account show -n $openAiName -g $openAiRg -o json | ConvertFrom-Json) -} else { - $openAi=$(az cognitiveservices account list -g $resourceGroup -o json | ConvertFrom-Json) - $openAiRg=$resourceGroup -} - -$openAiKey=$(az cognitiveservices account keys list -g $openAiRg -n $openAi.name -o json --query key1 | ConvertFrom-Json) - -## Getting App Insights instrumentation key, if required -$appinsightsId=@() -$appInsightsName=$(az resource list -g $resourceGroup --resource-type Microsoft.Insights/components --query [].name | ConvertFrom-Json) -if ($appInsightsName -and $appInsightsName.Length -eq 1) { - $appinsightsConfig=$(az monitor app-insights component show --app $appInsightsName -g $resourceGroup -o json | ConvertFrom-Json) - - if ($appinsightsConfig) { - $appinsightsId = $appinsightsConfig.instrumentationKey - $appinsightsConnectionString = $appinsightsConfig.connectionString - } -} -Write-Host "App Insights Instrumentation Key: $appinsightsId" -ForegroundColor Yellow - -## Showing Values that will be used - -Write-Host "===========================================================" -ForegroundColor Yellow -Write-Host "gvalues file will be generated with values:" - -$tokens.apiUrl=$apiUrl -$tokens.blobStorageConnectionString="DefaultEndpointsProtocol=https;AccountName=$($blobAccount);AccountKey=$blobKey;EndpointSuffix=core.windows.net" -$tokens.cosmosConnectionString="AccountEndpoint=$($docdb.documentEndpoint);AccountKey=$docdbKey" -$tokens.cosmosEndpoint=$docdb.documentEndpoint -$tokens.cosmosKey=$docdbKey -$tokens.openAiEndpoint=$openAi.properties.endpoint -$tokens.openAiKey=$openAiKey -$tokens.searchEndpoint="https://$($search.name).search.windows.net/" -$tokens.aiConnectionString=$appinsightsConnectionString - -# Standard fixed tokens -$tokens.ingressclass=$ingressClass -$tokens.ingressrewritepath="(/|$)(.*)" -$tokens.ingressrewritetarget="`$2" - -if($ingressClass -eq "nginx") { - $tokens.ingressrewritepath="(/|$)(.*)" - $tokens.ingressrewritetarget="`$2" -} - -Write-Host ($tokens | ConvertTo-Json) -ForegroundColor Yellow -Write-Host "===========================================================" -ForegroundColor Yellow - -Push-Location $($MyInvocation.InvocationName | Split-Path) -$gvaluesTemplatePath=$(./Join-Path-Recursively -pathParts $gvaluesTemplate.Split(",")) -$outputFilePath=$(./Join-Path-Recursively -pathParts $outputFile.Split(",")) -& ./Token-Replace.ps1 -inputFile $gvaluesTemplatePath -outputFile $outputFilePath -tokens $tokens -Pop-Location - -Push-Location $($MyInvocation.InvocationName | Split-Path) -$migrationSettingsTemplatePath=$(./Join-Path-Recursively -pathParts $migrationSettingsTemplate.Split(",")) -$outputFilePath=$(./Join-Path-Recursively -pathParts ..,migrationsettings.json) -& ./Token-Replace.ps1 -inputFile $migrationSettingsTemplatePath -outputFile $outputFilePath -tokens $tokens -Pop-Location \ No newline at end of file diff --git a/scripts/Import-Data-CloudShell.ps1 b/scripts/Import-Data-CloudShell.ps1 deleted file mode 100644 index 529c356..0000000 --- a/scripts/Import-Data-CloudShell.ps1 +++ /dev/null @@ -1,52 +0,0 @@ -#! /usr/bin/pwsh - -Param( - [parameter(Mandatory=$true)][string]$resourceGroup, - [parameter(Mandatory=$true)][string]$aksName -) - -Push-Location $($MyInvocation.InvocationName | Split-Path) - -$blobUri = "https://cosmosdbcosmicworks.blob.core.windows.net/cosmic-works-small/product.json" -$result = Invoke-WebRequest -Uri $blobUri -$products = $result.Content | ConvertFrom-Json -Write-Output "Imported $($products.Length) products" - -$blobUri = "https://cosmosdbcosmicworks.blob.core.windows.net/cosmic-works-small/customer.json" -$result = Invoke-WebRequest -Uri $blobUri -# The customers file has a BOM which needs to be ignored -$customers = $result.Content.Substring(1, $result.Content.Length - 1) | ConvertFrom-Json -Write-Output "Imported $($customers.Length) customers" - -$webappHostname=$(az aks show -n $aksName -g $resourceGroup -o json --query addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName | ConvertFrom-Json) -$apiUrl = "https://$webappHostname/api" -Write-Output "API Url is $apiUrl" - -$OldProgressPreference = $ProgressPreference -$ProgressPreference = "SilentlyContinue" - -$currentIndex = 0 -foreach($product in $products) -{ - Invoke-RestMethod -Uri $apiUrl/products -Method PUT -Body ($product | ConvertTo-Json) -ContentType 'application/json' - - $currentIndex += 1 - Write-Output "Imported product $currentIndex of $($products.Length)" -} - -$currentIndex = 0 -foreach($customer in $customers) -{ - if ($customer.type -eq "customer") { - Invoke-RestMethod -Uri $apiUrl/customers -Method PUT -Body ($customer | ConvertTo-Json) -ContentType 'application/json' - } elseif ($customer.type -eq "salesOrder") { - Invoke-RestMethod -Uri $apiUrl/salesorders -Method PUT -Body ($customer | ConvertTo-Json) -ContentType 'application/json' - } - - $currentIndex += 1 - Write-Output "Imported customer/sales order $currentIndex of $($customers.Length)" -} - -$ProgressPreference = $OldProgressPreference - -Pop-Location diff --git a/scripts/Import-Data.ps1 b/scripts/Import-Data.ps1 deleted file mode 100644 index c9e6916..0000000 --- a/scripts/Import-Data.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -Param( - [parameter(Mandatory=$true)][string]$resourceGroup, - [parameter(Mandatory=$true)][string]$cosmosDbAccountName -) - -Push-Location $($MyInvocation.InvocationName | Split-Path) -Push-Location .. -Remove-Item -Path dMT -Recurse -Force -ErrorAction Ignore -New-Item -ItemType Directory -Force -Path "dMT" -Push-Location "dMT" - -$dmtUrl="https://github.com/AzureCosmosDB/data-migration-desktop-tool/releases/download/2.1.1/dmt-2.1.1-win-x64.zip" -Invoke-WebRequest -Uri $dmtUrl -OutFile dmt.zip -Expand-Archive -Path dmt.zip -DestinationPath . -Push-Location "windows-package" -Copy-Item -Path "../../migrationsettings.json" -Destination "./migrationsettings.json" -Force - -#Write-Host "Bumping up the throughput on the customer container to avoid a known DMT issue..." -#az cosmosdb sql container throughput update --account-name $cosmosDbAccountName --database-name vsai-database --name customer --resource-group $resourceGroup --max-throughput 2000 - -& "./dmt.exe" - -#Write-Host "Restoring the throughput on the customer container..." -#az cosmosdb sql container throughput update --account-name $cosmosDbAccountName --database-name vsai-database --name customer --resource-group $resourceGroup --max-throughput 1000 - -Pop-Location -Pop-Location -Pop-Location -Pop-Location diff --git a/scripts/Join-Path-Recursively.ps1 b/scripts/Join-Path-Recursively.ps1 deleted file mode 100644 index 05a7138..0000000 --- a/scripts/Join-Path-Recursively.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -#! /usr/bin/pwsh - -Param( - [parameter(Mandatory=$false)][string[]]$pathParts -) - -if ($pathParts.Length -le 0) { - Write-Host "You need to call with at least one path part" -ForegroundColor Red - exit 1 -} - -if ($pathParts.Length -eq 1) { - Write-Output $pathParts[0] -} -else { - $childPath=$(./Join-Path-Recursively.ps1 -pathParts $pathParts[1..($pathParts.Length-1)]) - Join-Path -Path $pathParts[0] -ChildPath $childPath | Write-Output -} \ No newline at end of file diff --git a/scripts/Prepare-CloudShell-Deploy.ps1 b/scripts/Prepare-CloudShell-Deploy.ps1 deleted file mode 100644 index b4ee98e..0000000 --- a/scripts/Prepare-CloudShell-Deploy.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/pwsh - -Param( - [parameter(Mandatory=$true)][string]$resourceGroup, - [parameter(Mandatory=$true)][string]$acrName, - [parameter(Mandatory=$true)][string]$subscription, - [parameter(Mandatory=$false)][string]$dockerTag="latest" -) - -Push-Location $($MyInvocation.InvocationName | Split-Path) -$sourceFolder=$(./Join-Path-Recursively.ps1 -pathParts ..,scripts) - - -# Write-Host "Login in your account" -ForegroundColor Yellow -az login - -# Write-Host "Choosing your subscription" -ForegroundColor Yellow -az account set --subscription $subscription - -& ./BuildPush.ps1 -resourceGroup $resourceGroup -acrName $acrName -dockerTag $dockerTag -dockerBuild 1 -dockerPush 1 - -Pop-Location diff --git a/scripts/README.md b/scripts/README.md deleted file mode 100644 index 1ad9b2d..0000000 --- a/scripts/README.md +++ /dev/null @@ -1,74 +0,0 @@ -# Deployment - -## Using ACA - -Clone the BuildYourOwnCopilot repository and change to the `main` branch - -```pwsh -git clone https://github.com/Azure/BuildYourOwnCopilot -git checkout main -``` - -Run the following script to provision the infrastructure and deploy the API and frontend. This will provision all of the required infrastructure, deploy the API and web app services into ACA, and import data into Cosmos. - -```pwsh -./scripts/Unified-Deploy.ps1 -resourceGroup ` - -location ` - -subscription -``` - -## Using AKS - -Deployment using AKS instead of ACA requires the addition of the argument `-deployAks 1` to the command line call. - -```pwsh -./scripts/Unified-Deploy.ps1 -resourceGroup ` - -location ` - -subscription ` - -deployAks 1 -``` - -## Deployments using an existing OpenAI service - -For deployments that need to use an existing OpenAI service, run the following from the `scripts`. This will provision all of the necessary infrastruction except the Azure OpenAI service and will deploy the API and frontend to an AKS cluster via Helm. - -```pwsh -.\Unified-Deploy.ps1 -resourceGroup ` - -location ` - -subscription ` - -openAiName ` - -openAiRg ` - -openAiCompletionsDeployment ` - -openAiEmbeddingsDeployment -``` - -## Enabling/Disabling Deployment Steps - -The following flags can be used to enable/disable specific deployment steps in the `Unified-Deploy.ps1` script. - -| Parameter Name | Description | -|----------------|-------------| -| stepDeployArm | Enables or disables the provisioning of resources in Azure via ARM templates (located in `./arm`). Valid values are 0 (Disabled) and 1 (Enabled). See the `scripts/Deploy-Arm-Azure.ps1` script. -| stepBuildPush | Enables or disables the build and push of Docker images to the Azure Container Registry in the target resource group. Valid values are 0 (Disabled) and 1 (Enabled). See the `scripts/BuildPush.ps1` script. -| stepDeployCertManager | Enables or disables the Helm deployment of a LetsEncrypt capable certificate manager to the AKS cluster. Valid values are 0 (Disabled) and 1 (Enabled). See the `scripts/DeployCertManager.ps1` script. -| stepDeployTls | Enables or disables the Helm deployment of the LetsEncrypt certificate request resources to the AKS cluster. Valid values are 0 (Disabled) and 1 (Enabled). See the `scripts/PublishTlsSupport.ps1` script. -| stepDeployImages | Enables or disables the Helm deployment of the ChatAPI and UserPortal services to the AKS cluster. Valid values are 0 (Disabled) and 1 (Enabled). See the `scripts/Deploy-Images-Aks.ps1` script. -| stepUploadSystemPrompts | Enables or disables the upload of OpenAI system prompt artifacts to a storage account in the target resource group. Valid values are 0 (Disabled) and 1 (Enabled). See the `scripts/UploadSystemPrompts.ps1` script. -| stepImportData | Enables or disables the import of data into a Cosmos account in the target resource group using the Data Migration Tool. Valid values are 0 (Disabled) and 1 (Enabled). See the `scripts/Import-Data.ps1` script. -| stepLoginAzure | Enables or disables interactive Azure login. If disabled, the deployment assumes that the current Azure CLI session is valid. Valid values are 0 (Disabled). - -Example command: -```pwsh -cd deploy/powershell -./Unified-Deploy.ps1 -resourceGroup myRg ` - -subscription 0000... ` - -stepLoginAzure 0 ` - -stepDeployArm 0 ` - -stepBuildPush 1 ` - -stepDeployCertManager 0 ` - -stepDeployTls 0 ` - -stepDeployImages 1 ` - -stepUploadSystemPrompts 0 ` - -stepImportData 0 -``` - diff --git a/scripts/Token-Replace.ps1 b/scripts/Token-Replace.ps1 deleted file mode 100644 index 9863c26..0000000 --- a/scripts/Token-Replace.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -#! /usr/bin/pwsh - -# Token replace (https://gist.github.com/eiximenis/55361a2f60722f123ec49febb1399004) - -Param( - [parameter(Mandatory=$false,ValueFromPipeline=$true)][string]$content="", - [parameter(Mandatory=$false)][string]$inputFile="", - [parameter(Mandatory=$false)][string]$outputFile="", - [parameter(Mandatory=$true)][hashtable]$tokens -) - - -if ([string]::IsNullOrEmpty($content)) { - if ([string]::IsNullOrEmpty($inputFile)) { - Write-Host "Must enter -inputFile if content is not piped" -ForegroundColor Red - exit 1 - } - $content = Get-Content -Raw $inputFile -} - -$tokens.Keys | ForEach-Object ($_) { - $content = $content -replace "{{$_}}", $tokens[$_] -} - -if ([string]::IsNullOrEmpty($outputFile)) { - Write-Output $content -} -else { - Set-Content -Path $outputFile -Value $content -} diff --git a/scripts/Unified-Deploy.ps1 b/scripts/Unified-Deploy.ps1 deleted file mode 100644 index 663fad7..0000000 --- a/scripts/Unified-Deploy.ps1 +++ /dev/null @@ -1,195 +0,0 @@ -#! /usr/bin/pwsh - -Param( - [parameter(Mandatory=$false)][string]$acrName=$null, - [parameter(Mandatory=$true)][string]$resourceGroup, - [parameter(Mandatory=$true)][string]$location, - [parameter(Mandatory=$true)][string]$subscription, - [parameter(Mandatory=$false)][string]$armTemplate=$null, - [parameter(Mandatory=$false)][string]$openAiName=$null, - [parameter(Mandatory=$false)][string]$openAiRg=$null, - [parameter(Mandatory=$false)][string]$openAiCompletionsDeployment=$null, - [parameter(Mandatory=$false)][string]$openAiEmbeddingsDeployment=$null, - [parameter(Mandatory=$false)][bool]$stepDeployArm=$true, - [parameter(Mandatory=$false)][bool]$stepDeployOpenAi=$true, - [parameter(Mandatory=$false)][bool]$deployAks=$false, - [parameter(Mandatory=$false)][bool]$stepBuildPush=$true, - [parameter(Mandatory=$false)][bool]$stepDeployCertManager=$true, - [parameter(Mandatory=$false)][bool]$stepDeployTls=$true, - [parameter(Mandatory=$false)][bool]$stepDeployImages=$true, - [parameter(Mandatory=$false)][bool]$stepUploadSystemPrompts=$true, - [parameter(Mandatory=$false)][bool]$stepImportData=$true, - [parameter(Mandatory=$false)][bool]$stepLoginAzure=$true, - [parameter(Mandatory=$false)][string]$resourcePrefix=$null -) - -$gValuesFile="configFile.yaml" - -Push-Location $($MyInvocation.InvocationName | Split-Path) - -# Update the extension to make sure you have the latest version installed -az extension add --name aks-preview -az extension update --name aks-preview - -az extension add --name application-insights -az extension update --name application-insights - -az extension add --name storage-preview -az extension update --name storage-preview - -az extension add --name containerapp -az extension update --name containerapp - -if ($stepLoginAzure) { - # Write-Host "Login in your account" -ForegroundColor Yellow - az login -} - -# Write-Host "Choosing your subscription" -ForegroundColor Yellow -az account set --subscription $subscription - -$rg = $(az group show -g $resourceGroup -o json | ConvertFrom-Json) -if (-not $rg) { - $rg=$(az group create -g $resourceGroup -l $location --subscription $subscription) -} - -if (-not $resourcePrefix) { - $crypt = New-Object -TypeName System.Security.Cryptography.SHA256Managed - $utf8 = New-Object -TypeName System.Text.UTF8Encoding - $hash = [System.BitConverter]::ToString($crypt.ComputeHash($utf8.GetBytes($resourceGroup))) - $hash = $hash.replace('-','').toLower() - $resourcePrefix = $hash.Substring(0,5) -} - -if ($stepDeployOpenAi) { - if (-not $openAiRg) { - $openAiRg=$resourceGroup - } - - if (-not $openAiName) { - $openAiName = "$($resourcePrefix)-openai" - } - - if (-not $openAiCompletionsDeployment) { - $openAiCompletionsDeployment = "completions" - } - - if (-not $openAiEmbeddingsDeployment) { - $openAiEmbeddingsDeployment = "embeddings" - } - - & ./Deploy-OpenAi.ps1 -name $openAiName -resourceGroup $openAiRg -location $location -completionsDeployment $openAiCompletionsDeployment -embeddingsDeployment $openAiEmbeddingsDeployment -} - -## Getting OpenAI info -if ($openAiName) { - $openAi=$(az cognitiveservices account show -n $openAiName -g $openAiRg -o json | ConvertFrom-Json) -} else { - $openAi=$(az cognitiveservices account list -g $resourceGroup -o json | ConvertFrom-Json) - $openAiRg=$resourceGroup -} - -$openAiKey=$(az cognitiveservices account keys list -g $openAiRg -n $openAi.name -o json --query key1 | ConvertFrom-Json) - -if ($stepDeployArm) { - - if ([string]::IsNullOrEmpty($armTemplate)) - { - if ($deployAks) - { - $armTemplate="azuredeploy.json" - } - else - { - $armTemplate="azureAcaDeploy.json" - } - } - # Deploy ARM - & ./Deploy-Arm-Azure.ps1 -resourceGroup $resourceGroup -location $location -template $armTemplate -deployAks $deployAks -openAiEndpoint $openAi.properties.endpoint -openAiKey $openAiKey -openAiCompletionsDeployment $openAiCompletionsDeployment -openAiEmbeddingsDeployment $openAiEmbeddingsDeployment -} - -if ($deployAks) -{ - # Connecting kubectl to AKS - Write-Host "Retrieving Aks Name" -ForegroundColor Yellow - $aksName = $(az aks list -g $resourceGroup -o json | ConvertFrom-Json).name - Write-Host "The name of your AKS: $aksName" -ForegroundColor Yellow - - # Write-Host "Retrieving credentials" -ForegroundColor Yellow - az aks get-credentials -n $aksName -g $resourceGroup --overwrite-existing -} -else -{ - if ([string]::IsNullOrEmpty($cosmosDbAccountName)) - { - $cosmosDbAccountName=$(az deployment group show -g $resourceGroup -n cosmosdb-openai-azuredeploy -o json --query properties.outputs.cosmosDbAccountName.value | ConvertFrom-Json) - } -} - -# Generate Config -New-Item -ItemType Directory -Force -Path $(./Join-Path-Recursively.ps1 -pathParts ..,__values) -$gValuesLocation=$(./Join-Path-Recursively.ps1 -pathParts ..,__values,$gValuesFile) -& ./Generate-Config.ps1 -resourceGroup $resourceGroup -openAiName $openAiName -openAiRg $openAiRg -openAiDeployment $openAiDeployment -outputFile $gValuesLocation - -# Create Secrets -if ([string]::IsNullOrEmpty($acrName)) -{ - $acrName = $(az acr list --resource-group $resourceGroup -o json | ConvertFrom-Json).name -} - -Write-Host "The Name of your ACR: $acrName" -ForegroundColor Yellow -# & ./Create-Secret.ps1 -resourceGroup $resourceGroup -acrName $acrName - -if ($deployAks -And $stepDeployCertManager) { - # Deploy Cert Manager - & ./DeployCertManager.ps1 -} - -if ($deployAks -And $stepDeployTls) { - # Deploy TLS - & ./DeployTlsSupport.ps1 -sslSupport prod -resourceGroup $resourceGroup -aksName $aksName -} - -if ($stepBuildPush) { - # Build an Push - & ./BuildPush.ps1 -resourceGroup $resourceGroup -acrName $acrName -} - -if ($stepUploadSystemPrompts) { - # Upload System Prompts - & ./UploadSystemPrompts.ps1 -resourceGroup $resourceGroup -location $location -} - -if ($stepDeployImages) { - # Deploy images in AKS - $gValuesLocation=$(./Join-Path-Recursively.ps1 -pathParts ..,__values,$gValuesFile) - $chartsToDeploy = "*" - - if ($deployAks) { - & ./Deploy-Images-Aks.ps1 -aksName $aksName -resourceGroup $resourceGroup -charts $chartsToDeploy -acrName $acrName -valuesFile $gValuesLocation - } - else - { - & ./Deploy-Images-Aca.ps1 -resourceGroup $resourceGroup -acrName $acrName - } -} - -if ($stepImportData) { - # Import Data - & ./Import-Data.ps1 -resourceGroup $resourceGroup -cosmosDbAccountName $cosmosDbAccountName -} - -if ($deployAks) -{ - $webappHostname=$(az aks show -n $aksName -g $resourceGroup -o json --query addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName | ConvertFrom-Json) -} -else -{ - $webappHostname=$(az deployment group show -g $resourceGroup -n cosmosdb-openai-azuredeploy -o json --query properties.outputs.webFqdn.value | ConvertFrom-Json) -} - -Write-Host "===========================================================" -ForegroundColor Yellow -Write-Host "The frontend is hosted at https://$webappHostname" -ForegroundColor Yellow -Write-Host "===========================================================" -ForegroundColor Yellow - -Pop-Location diff --git a/scripts/UploadSystemPrompts.ps1 b/scripts/UploadSystemPrompts.ps1 deleted file mode 100644 index dbeec66..0000000 --- a/scripts/UploadSystemPrompts.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/pwsh - -Param( - [parameter(Mandatory=$true)][string]$resourceGroup, - [parameter(Mandatory=$true)][string]$location -) - -Push-Location $($MyInvocation.InvocationName | Split-Path) -Push-Location .. - -$storageAccount = $(az storage account list -g $resourceGroup -o json | ConvertFrom-Json).name -az storage container create --account-name $storageAccount --name "system-prompt" --only-show-errors -az storage azcopy blob upload -c system-prompt --account-name $storageAccount -s "./SystemPrompts/*" --recursive --only-show-errors - -az storage container create --account-name $storageAccount --name "memory-source" --only-show-errors -az storage azcopy blob upload -c memory-source --account-name $storageAccount -s "./MemorySources/*.json" --recursive --only-show-errors - -az storage container create --account-name $storageAccount --name "product-policy" --only-show-errors -az storage azcopy blob upload -c product-policy --account-name $storageAccount -s "./MemorySources/*.txt" --recursive --only-show-errors - -Pop-Location -Pop-Location diff --git a/scripts/VMScriptExtension.ps1 b/scripts/VMScriptExtension.ps1 deleted file mode 100644 index b21445a..0000000 --- a/scripts/VMScriptExtension.ps1 +++ /dev/null @@ -1,13 +0,0 @@ -Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - -$Env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") - -choco install --yes kubernetes-helm -choco install --yes azure-cli -choco install --yes kubernetes-cli -choco install --yes git.install -choco install --yes docker-desktop -choco install --yes nodejs.install -choco install --yes nvm -choco install --yes wsl2 --params "/Version:2 /Retry:true" -