From ca8804cec200d6b84e0a44d1fea2213a0b54a5e7 Mon Sep 17 00:00:00 2001 From: Cephas Lin Date: Fri, 28 Jun 2024 11:40:49 +0200 Subject: [PATCH 1/5] Remove infra files --- Program.cs | 21 +- azure.yaml | 51 ----- infra/README.md | 3 - infra/main.bicep | 45 ----- infra/main.parameters.json | 18 -- infra/resources.bicep | 402 ------------------------------------- 6 files changed, 10 insertions(+), 530 deletions(-) delete mode 100644 azure.yaml delete mode 100644 infra/README.md delete mode 100644 infra/main.bicep delete mode 100644 infra/main.parameters.json delete mode 100644 infra/resources.bicep diff --git a/Program.cs b/Program.cs index cd5e3cea8..ffa365722 100644 --- a/Program.cs +++ b/Program.cs @@ -9,17 +9,16 @@ options.UseSqlServer(builder.Configuration.GetConnectionString("MyDbConnection"))); builder.Services.AddDistributedMemoryCache(); } -else -{ - builder.Services.AddDbContext(options => - options.UseSqlServer(builder.Configuration.GetConnectionString("AZURE_SQL_CONNECTIONSTRING"))); - builder.Services.AddStackExchangeRedisCache(options => - { - options.Configuration = builder.Configuration["AZURE_REDIS_CONNECTIONSTRING"]; - options.InstanceName = "SampleInstance"; - }); -} - +// else +// { +// builder.Services.AddDbContext(options => +// options.UseSqlServer(builder.Configuration.GetConnectionString("AZURE_SQL_CONNECTIONSTRING"))); +// builder.Services.AddStackExchangeRedisCache(options => +// { +// options.Configuration = builder.Configuration["AZURE_REDIS_CONNECTIONSTRING"]; +// options.InstanceName = "SampleInstance"; +// }); +// } // Add services to the container. builder.Services.AddControllersWithViews(); diff --git a/azure.yaml b/azure.yaml deleted file mode 100644 index 9943c9176..000000000 --- a/azure.yaml +++ /dev/null @@ -1,51 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json -# azure.yaml is an azd configuration file and isn't used by the sample application. - -name: dotnet-app-service-sqldb-redis-infra -metadata: - template: dotnet-app-service-sqldb-redis-infra@0.0.1-beta -services: - web: - project: . - language: csharp - host: appservice -hooks: - # The prepackage hook is used to create a runnable migrations bundle to be run in App Service. - # The migrationsbundle file is included in DotNetCoreSqlDb.csproj so it can be included in the deploy package. - prepackage: - posix: - shell: sh - run: dotnet ef migrations bundle --runtime linux-x64 --force -o migrationsbundle - interactive: true - continueOnError: true - # The postpackage hook is used to remove the migrationsbundle file after deploy package is created. - postpackage: - posix: - shell: sh - run: rm migrationsbundle - interactive: true - continueOnError: true - # The postprovision hook is used to display the connection strings and app settings for the App Service app. - postprovision: - posix: - shell: sh - run: printf '\nApp Service app has the following connection strings:\n' && printf "$CONNECTION_SETTINGS" | jq -r '.[]' | sed 's/\(.*\)/\t- \1/' && printf "\nSee the settings in the portal:\n\033[1;36m$WEB_APP_CONNECTIONSTRINGS\n$WEB_APP_APPSETTINGS\n" - interactive: true - continueOnError: true - windows: - shell: pwsh - run: Write-Host "`n`nApp Service app has the following connection strings:`n" $CONNECTION_SETTINGS | ConvertFrom-Json | ForEach-Object { Write-Host "\t- $_" } - interactive: true - continueOnError: true - # The postdeploy hook is used to display the SSH session and log stream URLs for the App Service app. - postdeploy: - posix: - shell: sh - run: printf "Open SSH session to App Service container at:\033[1;36m $WEB_APP_SSH\033[0m\nStream App Service logs at:\033[1;36m $WEB_APP_LOG_STREAM\n" - interactive: true - continueOnError: true - windows: - shell: pwsh - run: Write-Host "`n`nOpen SSH session to App Service container at:`n" $WEB_APP_SSH; Write-Host "Stream App Service logs at:`n" $WEB_APP_LOG_STREAM - interactive: true - continueOnError: true \ No newline at end of file diff --git a/infra/README.md b/infra/README.md deleted file mode 100644 index 7a32cf062..000000000 --- a/infra/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# infra directory - -This `infra` directory contains azd files used for `azd provision` and isn't used by the sample application. \ No newline at end of file diff --git a/infra/main.bicep b/infra/main.bicep deleted file mode 100644 index 35643ccae..000000000 --- a/infra/main.bicep +++ /dev/null @@ -1,45 +0,0 @@ -targetScope = 'subscription' - -@minLength(1) -@maxLength(64) -@description('Name which is used to generate a short unique hash for each resource') -param name string - -@minLength(1) -@description('Primary location for all resources') -param location string - -@secure() -@description('SQL Server administrator password') -param databasePassword string - -param principalId string = '' - -var resourceToken = toLower(uniqueString(subscription().id, name, location)) - -resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { - name: '${name}_group' - location: location - tags: { 'azd-env-name': name } -} - -module resources 'resources.bicep' = { - name: 'resources' - scope: resourceGroup - params: { - name: name - location: location - resourceToken: resourceToken - databasePassword: databasePassword - principalId: principalId - } -} - -output AZURE_LOCATION string = location -output WEB_URI string = resources.outputs.WEB_URI -output CONNECTION_SETTINGS array = resources.outputs.CONNECTION_SETTINGS -output WEB_APP_LOG_STREAM string = resources.outputs.WEB_APP_LOG_STREAM -output WEB_APP_SSH string = resources.outputs.WEB_APP_SSH -output WEB_APP_CONNECTIONSTRINGS string = resources.outputs.WEB_APP_CONNECTIONSTRINGS -output WEB_APP_APPSETTINGS string = resources.outputs.WEB_APP_APPSETTINGS -output AZURE_KEY_VAULT_NAME string = resources.outputs.AZURE_KEY_VAULT_NAME diff --git a/infra/main.parameters.json b/infra/main.parameters.json deleted file mode 100644 index 2a116461d..000000000 --- a/infra/main.parameters.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "${AZURE_ENV_NAME}" - }, - "location": { - "value": "${AZURE_LOCATION}" - }, - "principalId": { - "value": "${AZURE_PRINCIPAL_ID}" - }, - "databasePassword": { - "value": "$(secretOrRandomPassword ${AZURE_KEY_VAULT_NAME} databasePassword)" - } - } - } \ No newline at end of file diff --git a/infra/resources.bicep b/infra/resources.bicep deleted file mode 100644 index 465370764..000000000 --- a/infra/resources.bicep +++ /dev/null @@ -1,402 +0,0 @@ -param name string -param location string -param resourceToken string -param principalId string = '' -@secure() -param databasePassword string - -var appName = '${name}-${resourceToken}' - -// The Key Vault is for saving the randomly generated password -resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' = { - name: '${take(replace(appName, '-', ''), 17)}-vault' - location: location - properties: { - tenantId: subscription().tenantId - sku: { family: 'A', name: 'standard' } - accessPolicies: [ - { - objectId: principalId - permissions: { secrets: [ 'get', 'list' ] } - tenantId: subscription().tenantId - } - ] - } -} -resource keyVaultSecret 'Microsoft.KeyVault/vaults/secrets@2022-07-01' = { - name: 'databasePassword' - parent: keyVault - properties: { - contentType: 'string' - value: databasePassword - } -} - -resource virtualNetwork 'Microsoft.Network/virtualNetworks@2023-04-01' = { - location: location - name: '${appName}Vnet' - properties: { - addressSpace: { - addressPrefixes: ['10.0.0.0/16'] - } - subnets: [ - { - name: 'cache-subnet' - properties: { - addressPrefix: '10.0.0.0/24' - privateEndpointNetworkPolicies: 'Disabled' - } - } - { - name: 'database-subnet' - properties: { - addressPrefix: '10.0.2.0/24' - privateEndpointNetworkPolicies: 'Disabled' - } - } - { - name: 'webapp-subnet' - properties: { - delegations: [ - { - name: 'dlg-appServices' - properties: { - serviceName: 'Microsoft.Web/serverfarms' - } - } - ] - serviceEndpoints: [] - addressPrefix: '10.0.1.0/24' - } - } - ] - } - resource subnetForDb 'subnets' existing = { - name: 'database-subnet' - } - resource subnetForApp 'subnets' existing = { - name: 'webapp-subnet' - } - resource subnetForCache 'subnets' existing = { - name: 'cache-subnet' - } -} - -resource privateDnsZoneDB 'Microsoft.Network/privateDnsZones@2020-06-01' = { - name: 'privatelink.database.windows.net' - location: 'global' - dependsOn: [ - virtualNetwork - ] -} - -resource privateDnsZoneLinkDB 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2020-06-01' = { - parent: privateDnsZoneDB - name: '${appName}-dblink' - location: 'global' - properties: { - virtualNetwork: { - id: virtualNetwork.id - } - registrationEnabled: false - } -} - -resource privateDnsZoneCache 'Microsoft.Network/privateDnsZones@2020-06-01' = { - name: 'privatelink.redis.cache.windows.net' - location: 'global' - dependsOn: [ - virtualNetwork - ] -} - -resource privateDnsZoneLinkCache 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2020-06-01' = { - parent: privateDnsZoneCache - name: '${appName}-cachelink' - location: 'global' - properties: { - virtualNetwork: { - id: virtualNetwork.id - } - registrationEnabled: false - } -} - -resource dbPrivateEndpoint 'Microsoft.Network/privateEndpoints@2023-04-01' = { - name: '${appName}-db-privateEndpoint' - location: location - properties: { - subnet: { - id: virtualNetwork::subnetForDb.id - } - privateLinkServiceConnections: [ - { - name: '${appName}-db-privateEndpoint' - properties: { - privateLinkServiceId: dbserver.id - groupIds: ['sqlServer'] - } - } - ] - } - resource dbPrivateDnsZoneGroup 'privateDnsZoneGroups' = { - name: 'default' - properties: { - privateDnsZoneConfigs: [ - { - name: 'privatelink-database-windows-net' - properties: { - privateDnsZoneId: privateDnsZoneDB.id - } - } - ] - } - } -} - -// The SQL Database server is configured to be the minimum pricing tier -resource dbserver 'Microsoft.Sql/servers@2023-05-01-preview' = { - location: location - name: '${appName}-server' - properties: { - administratorLogin: '${appName}-server-admin' - administratorLoginPassword: databasePassword - publicNetworkAccess: 'Disabled' - restrictOutboundNetworkAccess: 'Disabled' - } - dependsOn: [ - privateDnsZoneLinkDB - ] -} - -resource db 'Microsoft.Sql/servers/databases@2023-05-01-preview' = { - parent: dbserver - location: location - name: '${appName}-database' - sku: { - name: 'GP_S_Gen5' - tier: 'GeneralPurpose' - family: 'Gen5' - capacity: 1 - } -} - -resource cachePrivateEndpoint 'Microsoft.Network/privateEndpoints@2023-04-01' = { - name: '${appName}-cache-privateEndpoint' - location: location - properties: { - subnet: { - id: virtualNetwork::subnetForCache.id - } - privateLinkServiceConnections: [ - { - name: '${appName}-cache-privateEndpoint' - properties: { - privateLinkServiceId: redisCache.id - groupIds: ['redisCache'] - } - } - ] - } - resource cachePrivateDnsZoneGroup 'privateDnsZoneGroups' = { - name: 'default' - properties: { - privateDnsZoneConfigs: [ - { - name: 'privatelink-redis-cache-windows-net' - properties: { - privateDnsZoneId: privateDnsZoneCache.id - } - } - ] - } - } -} - -// The Redis cache is configured to the minimum pricing tier -resource redisCache 'Microsoft.Cache/Redis@2023-08-01' = { - name: '${appName}-cache' - location: location - properties: { - sku: { - name: 'Basic' - family: 'C' - capacity: 0 - } - redisConfiguration: {} - enableNonSslPort: false - redisVersion: '6' - publicNetworkAccess: 'Disabled' - } -} - -// The App Service plan is configured to the B1 pricing tier -resource appServicePlan 'Microsoft.Web/serverfarms@2022-09-01' = { - name: '${appName}-plan' - location: location - kind: 'linux' - properties: { - reserved: true - } - sku: { - name: 'B1' - } -} - -resource web 'Microsoft.Web/sites@2022-09-01' = { - name: appName - location: location - tags: {'azd-service-name': 'web'} // Needed by AZD - properties: { - siteConfig: { - linuxFxVersion: 'DOTNETCORE|8.0' // Set to .NET 8 (LTS) - vnetRouteAllEnabled: true // Route outbound traffic to the VNET - ftpsState: 'Disabled' - appCommandLine: './migrationsbundle -- --environment Production && dotnet "DotNetCoreSqlDb.dll"' - } - serverFarmId: appServicePlan.id - httpsOnly: true - } - - // Enable App Service native logs - resource logs 'config' = { - name: 'logs' - properties: { - applicationLogs: { - fileSystem: { - level: 'Verbose' - } - } - detailedErrorMessages: { - enabled: true - } - failedRequestsTracing: { - enabled: true - } - httpLogs: { - fileSystem: { - enabled: true - retentionInDays: 1 - retentionInMb: 35 - } - } - } - } - - // Enable VNET integration - resource webappVnetConfig 'networkConfig' = { - name: 'virtualNetwork' - properties: { - subnetResourceId: virtualNetwork::subnetForApp.id - } - } - - dependsOn: [virtualNetwork] -} - -// Connector to the SQL Server database, which generates the connection string for the App Service app -resource dbConnector 'Microsoft.ServiceLinker/linkers@2022-05-01' = { - scope: web - name: 'defaultConnector' - properties: { - targetService: { - type: 'AzureResource' - id: db.id - } - authInfo: { - authType: 'secret' - name: '${appName}-server-admin' - secretInfo: { - secretType: 'rawValue' - value: databasePassword - } - } - clientType: 'dotnet-connectionString' - vNetSolution: { - type: 'privateLink' - } - } -} - -// Connector to the Redis cache, which generates the connection string for the App Service app -resource cacheConnector 'Microsoft.ServiceLinker/linkers@2022-05-01' = { - scope: web - name: 'RedisConnector' - properties: { - targetService: { - type: 'AzureResource' - id: resourceId('Microsoft.Cache/Redis/Databases', redisCache.name, '0') - } - authInfo: { - authType: 'secret' - } - clientType: 'dotnet' - vNetSolution: { - type: 'privateLink' - } - } -} - -resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03-01-preview' = { - name: '${appName}-workspace' - location: location - properties: any({ - retentionInDays: 30 - features: { - searchVersion: 1 - } - sku: { - name: 'PerGB2018' - } - }) -} - -// Enable log shipping from the App Service app to the Log Analytics workspace. -resource webdiagnostics 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = { - name: 'AllLogs' - scope: web - properties: { - workspaceId: logAnalyticsWorkspace.id - logs: [ - { - category: 'AppServiceHTTPLogs' - enabled: true - } - { - category: 'AppServiceConsoleLogs' - enabled: true - } - { - category: 'AppServiceAppLogs' - enabled: true - } - { - category: 'AppServiceAuditLogs' - enabled: true - } - { - category: 'AppServiceIPSecAuditLogs' - enabled: true - } - { - category: 'AppServicePlatformLogs' - enabled: true - } - ] - metrics: [ - { - category: 'AllMetrics' - enabled: true - } - ] - } -} - -output WEB_URI string = 'https://${web.properties.defaultHostName}' - -output CONNECTION_SETTINGS array = [dbConnector.listConfigurations().configurations[0].name, cacheConnector.listConfigurations().configurations[0].name] -output WEB_APP_LOG_STREAM string = format('https://portal.azure.com/#@/resource{0}/logStream', web.id) -output WEB_APP_SSH string = format('https://{0}.scm.azurewebsites.net/webssh/host', web.name) -output WEB_APP_CONNECTIONSTRINGS string = format('https://portal.azure.com/#@/resource{0}/connectionStrings', web.id) -output WEB_APP_APPSETTINGS string = format('https://portal.azure.com/#@/resource{0}/environmentVariablesAppSettings', web.id) -output AZURE_KEY_VAULT_NAME string = keyVault.name From af07054e2172b1cc825235c5b536dfa614c1c538 Mon Sep 17 00:00:00 2001 From: Azuregit100 Date: Sun, 15 Sep 2024 16:54:43 -0400 Subject: [PATCH 2/5] Add or update the Azure App Service build and deployment workflow config --- .../starter-no-infra_msdocs-core-sql-bkr.yml | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/starter-no-infra_msdocs-core-sql-bkr.yml diff --git a/.github/workflows/starter-no-infra_msdocs-core-sql-bkr.yml b/.github/workflows/starter-no-infra_msdocs-core-sql-bkr.yml new file mode 100644 index 000000000..d7506884f --- /dev/null +++ b/.github/workflows/starter-no-infra_msdocs-core-sql-bkr.yml @@ -0,0 +1,65 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy ASP.Net Core app to Azure Web App - msdocs-core-sql-BKR + +on: + push: + branches: + - starter-no-infra + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.x' + + - name: Build with dotnet + run: dotnet build --configuration Release + + - name: dotnet publish + run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v4 + with: + name: .net-app + path: ${{env.DOTNET_ROOT}}/myapp + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + permissions: + id-token: write #This is required for requesting the JWT + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v4 + with: + name: .net-app + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_35BD3300570A468CAD1821F29FB6EA6F }} + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_AA47BBAF1358488B9F8FBF2D13596B4F }} + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_047C3DAF5D6A43F5820F945416A215E8 }} + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v3 + with: + app-name: 'msdocs-core-sql-BKR' + slot-name: 'Production' + package: . + \ No newline at end of file From 342546a328972feecb7dca0f0b97679bafa63886 Mon Sep 17 00:00:00 2001 From: Azuregit100 Date: Sun, 15 Sep 2024 21:24:45 +0000 Subject: [PATCH 3/5] Configure Azure database and cache connections --- .../starter-no-infra_msdocs-core-sql-bkr.yml | 24 ++++++++++++------- Program.cs | 20 ++++++++-------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.github/workflows/starter-no-infra_msdocs-core-sql-bkr.yml b/.github/workflows/starter-no-infra_msdocs-core-sql-bkr.yml index d7506884f..53b3542f1 100644 --- a/.github/workflows/starter-no-infra_msdocs-core-sql-bkr.yml +++ b/.github/workflows/starter-no-infra_msdocs-core-sql-bkr.yml @@ -27,6 +27,12 @@ jobs: - name: dotnet publish run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp + - name: Install dotnet ef + run: dotnet tool install -g dotnet-ef --version 8.* + + - name: Create migrations bundle + run: dotnet ef migrations bundle --runtime linux-x64 -o ${{env.DOTNET_ROOT}}/myapp/migrationsbundle + - name: Upload artifact for deployment job uses: actions/upload-artifact@v4 with: @@ -39,21 +45,21 @@ jobs: environment: name: 'Production' url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} - permissions: - id-token: write #This is required for requesting the JWT + permissions: + id-token: write #This is required for requesting the JWT steps: - name: Download artifact from build job uses: actions/download-artifact@v4 with: name: .net-app - - - name: Login to Azure - uses: azure/login@v2 - with: - client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_35BD3300570A468CAD1821F29FB6EA6F }} - tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_AA47BBAF1358488B9F8FBF2D13596B4F }} - subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_047C3DAF5D6A43F5820F945416A215E8 }} + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_35BD3300570A468CAD1821F29FB6EA6F }} + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_AA47BBAF1358488B9F8FBF2D13596B4F }} + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_047C3DAF5D6A43F5820F945416A215E8 }} - name: Deploy to Azure Web App id: deploy-to-webapp diff --git a/Program.cs b/Program.cs index ffa365722..f3caf8742 100644 --- a/Program.cs +++ b/Program.cs @@ -9,16 +9,16 @@ options.UseSqlServer(builder.Configuration.GetConnectionString("MyDbConnection"))); builder.Services.AddDistributedMemoryCache(); } -// else -// { -// builder.Services.AddDbContext(options => -// options.UseSqlServer(builder.Configuration.GetConnectionString("AZURE_SQL_CONNECTIONSTRING"))); -// builder.Services.AddStackExchangeRedisCache(options => -// { -// options.Configuration = builder.Configuration["AZURE_REDIS_CONNECTIONSTRING"]; -// options.InstanceName = "SampleInstance"; -// }); -// } +else +{ + builder.Services.AddDbContext(options => + options.UseSqlServer(builder.Configuration.GetConnectionString("AZURE_SQL_CONNECTIONSTRING"))); + builder.Services.AddStackExchangeRedisCache(options => + { + options.Configuration = builder.Configuration["AZURE_REDIS_CONNECTIONSTRING"]; + options.InstanceName = "SampleInstance"; + }); + } // Add services to the container. builder.Services.AddControllersWithViews(); From 441bb2bade673f51fa61cef544fb0abd79e30ce5 Mon Sep 17 00:00:00 2001 From: Azuregit100 Date: Sun, 15 Sep 2024 22:44:34 +0000 Subject: [PATCH 4/5] Configure Azure database and cache connections --- .github/workflows/starter-no-infra_msdocs-core-sql-bkr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/starter-no-infra_msdocs-core-sql-bkr.yml b/.github/workflows/starter-no-infra_msdocs-core-sql-bkr.yml index 53b3542f1..69764f852 100644 --- a/.github/workflows/starter-no-infra_msdocs-core-sql-bkr.yml +++ b/.github/workflows/starter-no-infra_msdocs-core-sql-bkr.yml @@ -28,7 +28,7 @@ jobs: run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp - name: Install dotnet ef - run: dotnet tool install -g dotnet-ef --version 8.* + run: dotnet tool install --g dotnet-ef --version 8.* - name: Create migrations bundle run: dotnet ef migrations bundle --runtime linux-x64 -o ${{env.DOTNET_ROOT}}/myapp/migrationsbundle From 78dcac70371fd011ccb57d1f91266060f5fc32f9 Mon Sep 17 00:00:00 2001 From: Azuregit100 Date: Tue, 17 Sep 2024 11:24:55 -0400 Subject: [PATCH 5/5] Add or update the Azure App Service build and deployment workflow config --- .../starter-no-infra_aspnetcore-sql-bkr.yml | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/starter-no-infra_aspnetcore-sql-bkr.yml diff --git a/.github/workflows/starter-no-infra_aspnetcore-sql-bkr.yml b/.github/workflows/starter-no-infra_aspnetcore-sql-bkr.yml new file mode 100644 index 000000000..d456168d1 --- /dev/null +++ b/.github/workflows/starter-no-infra_aspnetcore-sql-bkr.yml @@ -0,0 +1,65 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy ASP.Net Core app to Azure Web App - aspnetcore-sql-bkr + +on: + push: + branches: + - starter-no-infra + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.x' + + - name: Build with dotnet + run: dotnet build --configuration Release + + - name: dotnet publish + run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v4 + with: + name: .net-app + path: ${{env.DOTNET_ROOT}}/myapp + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + permissions: + id-token: write #This is required for requesting the JWT + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v4 + with: + name: .net-app + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_05F6A10643374E0498A68911A5E98557 }} + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_FA60D66E92564053BE334F8A53580270 }} + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_C84286698407454684463E9583706990 }} + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v3 + with: + app-name: 'aspnetcore-sql-bkr' + slot-name: 'Production' + package: . + \ No newline at end of file