diff --git a/.github/workflows/azureprojectgenerator.yml b/.github/workflows/azureprojectgenerator.yml new file mode 100644 index 0000000..bb26a5d --- /dev/null +++ b/.github/workflows/azureprojectgenerator.yml @@ -0,0 +1,37 @@ +name: Build and deploy .NET Core application to Function App azureprojectgenerator +on: + push: + branches: + - generatesmallerprojects +env: + AZURE_FUNCTIONAPP_NAME: azureprojectgenerator + AZURE_FUNCTIONAPP_PACKAGE_PATH: azure-project-generator + DOTNET_VERSION: 8.0.x + +jobs: + build-and-deploy: + runs-on: ubuntu-latest # For Linux, use ubuntu-latest + environment: dev + steps: + - name: 'Checkout GitHub Action' + uses: actions/checkout@v3 + + - name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: 'Resolve Project Dependencies Using Dotnet' + shell: pwsh # For Linux, use bash + run: | + pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}' + dotnet build --configuration Release --output ./output + popd + + - name: 'Run Azure Functions Action' + uses: Azure/functions-action@v1 + id: fa + with: + app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }} + package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output' + publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} diff --git a/azure-project-generator/Program.cs b/azure-project-generator/Program.cs index 5e3f857..240db6b 100644 --- a/azure-project-generator/Program.cs +++ b/azure-project-generator/Program.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.Hosting; var host = new HostBuilder() - .ConfigureFunctionsWorkerDefaults() + .ConfigureFunctionsWebApplication() .ConfigureServices((context, services) => { services.AddApplicationInsightsTelemetryWorkerService(); diff --git a/azure-project-generator/Properties/ServiceDependencies/azureprojectgenerator/appInsights1.arm.json b/azure-project-generator/Properties/ServiceDependencies/azureprojectgenerator/appInsights1.arm.json new file mode 100644 index 0000000..380de34 --- /dev/null +++ b/azure-project-generator/Properties/ServiceDependencies/azureprojectgenerator/appInsights1.arm.json @@ -0,0 +1,67 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "resourceGroupName": { + "type": "string", + "defaultValue": "azureprojectgenerator-rg", + "metadata": { + "_parameterType": "resourceGroup", + "description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking." + } + }, + "resourceGroupLocation": { + "type": "string", + "defaultValue": "eastus", + "metadata": { + "_parameterType": "location", + "description": "Location of the resource group. Resource groups could have different location than resources." + } + }, + "resourceLocation": { + "type": "string", + "defaultValue": "[parameters('resourceGroupLocation')]", + "metadata": { + "_parameterType": "location", + "description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there." + } + } + }, + "resources": [ + { + "type": "Microsoft.Resources/resourceGroups", + "name": "[parameters('resourceGroupName')]", + "location": "[parameters('resourceGroupLocation')]", + "apiVersion": "2019-10-01" + }, + { + "type": "Microsoft.Resources/deployments", + "name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat('azure-project-generator', subscription().subscriptionId)))]", + "resourceGroup": "[parameters('resourceGroupName')]", + "apiVersion": "2019-10-01", + "dependsOn": [ + "[parameters('resourceGroupName')]" + ], + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [ + { + "kind": "web", + "name": "azure-project-generator", + "type": "microsoft.insights/components", + "location": "[parameters('resourceLocation')]", + "properties": {}, + "apiVersion": "2015-05-01" + } + ] + } + } + } + ], + "metadata": { + "_dependencyType": "appInsights.azure" + } +} \ No newline at end of file diff --git a/azure-project-generator/Properties/ServiceDependencies/azureprojectgenerator/storage1.arm.json b/azure-project-generator/Properties/ServiceDependencies/azureprojectgenerator/storage1.arm.json new file mode 100644 index 0000000..cb635bd --- /dev/null +++ b/azure-project-generator/Properties/ServiceDependencies/azureprojectgenerator/storage1.arm.json @@ -0,0 +1,70 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "resourceGroupName": { + "type": "string", + "defaultValue": "azureprojectgenerator-rg", + "metadata": { + "_parameterType": "resourceGroup", + "description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking." + } + }, + "resourceGroupLocation": { + "type": "string", + "defaultValue": "eastus", + "metadata": { + "_parameterType": "location", + "description": "Location of the resource group. Resource groups could have different location than resources." + } + }, + "resourceLocation": { + "type": "string", + "defaultValue": "[parameters('resourceGroupLocation')]", + "metadata": { + "_parameterType": "location", + "description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there." + } + } + }, + "resources": [ + { + "type": "Microsoft.Resources/resourceGroups", + "name": "[parameters('resourceGroupName')]", + "location": "[parameters('resourceGroupLocation')]", + "apiVersion": "2019-10-01" + }, + { + "type": "Microsoft.Resources/deployments", + "name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat('azureprojectgenstor', subscription().subscriptionId)))]", + "resourceGroup": "[parameters('resourceGroupName')]", + "apiVersion": "2019-10-01", + "dependsOn": [ + "[parameters('resourceGroupName')]" + ], + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [ + { + "sku": { + "name": "Standard_RAGRS", + "tier": "Standard" + }, + "kind": "StorageV2", + "name": "azureprojectgenstor", + "type": "Microsoft.Storage/storageAccounts", + "location": "[parameters('resourceLocation')]", + "apiVersion": "2017-10-01" + } + ] + } + } + } + ], + "metadata": { + "_dependencyType": "storage.azure" + } +} \ No newline at end of file diff --git a/azure-project-generator/Properties/serviceDependencies.azureprojectgenerator.json b/azure-project-generator/Properties/serviceDependencies.azureprojectgenerator.json new file mode 100644 index 0000000..c0eb4f4 --- /dev/null +++ b/azure-project-generator/Properties/serviceDependencies.azureprojectgenerator.json @@ -0,0 +1,14 @@ +{ + "dependencies": { + "appInsights1": { + "resourceId": "/subscriptions/[parameters('subscriptionId')]/resourceGroups/[parameters('resourceGroupName')]/providers/microsoft.insights/components/azure-project-generator", + "type": "appInsights.azure", + "connectionId": "APPLICATIONINSIGHTS_CONNECTION_STRING" + }, + "storage1": { + "resourceId": "/subscriptions/[parameters('subscriptionId')]/resourceGroups/[parameters('resourceGroupName')]/providers/Microsoft.Storage/storageAccounts/azureprojectgenstor", + "type": "storage.azure", + "connectionId": "AzureWebJobsStorage" + } + } +} \ No newline at end of file diff --git a/azure-project-generator/Properties/serviceDependencies.json b/azure-project-generator/Properties/serviceDependencies.json index 0b7b98a..498af49 100644 --- a/azure-project-generator/Properties/serviceDependencies.json +++ b/azure-project-generator/Properties/serviceDependencies.json @@ -1,12 +1,5 @@ { "dependencies": { - "appInsights1": { - "type": "appInsights" - }, - "storage1": { - "type": "storage", - "connectionId": "AzureWebJobsStorage" - }, "secrets1": { "type": "secrets" }, @@ -14,6 +7,14 @@ "type": "storage", "connectionId": "azurestorage", "dynamicId": null + }, + "appInsights1": { + "type": "appInsights", + "connectionId": "APPLICATIONINSIGHTS_CONNECTION_STRING" + }, + "storage1": { + "type": "storage", + "connectionId": "AzureWebJobsStorage" } } } \ No newline at end of file diff --git a/azure-project-generator/azure-project-generator.csproj b/azure-project-generator/azure-project-generator.csproj index 1a87338..551488a 100644 --- a/azure-project-generator/azure-project-generator.csproj +++ b/azure-project-generator/azure-project-generator.csproj @@ -21,7 +21,7 @@ - + diff --git a/azure-project-generator/services/ContentGenerationService.cs b/azure-project-generator/services/ContentGenerationService.cs index 5f59657..4e0989c 100644 --- a/azure-project-generator/services/ContentGenerationService.cs +++ b/azure-project-generator/services/ContentGenerationService.cs @@ -17,7 +17,6 @@ public ContentGenerationService(ILogger logger, Embedd _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _embeddingClient = embeddingClient ?? throw new ArgumentNullException(nameof(embeddingClient)); _completionsClient = completionsClient ?? throw new ArgumentNullException(nameof(completionsClient)); - } public string GenerateCertServiceContextSentence(CertificationService data) =>