From 57cb7a6c109ed16a74f6ef3e6f1dfb426709babc Mon Sep 17 00:00:00 2001 From: Lu1zEdu Date: Thu, 20 Nov 2025 17:31:04 -0300 Subject: [PATCH 1/3] Colocando as pipelines --- azure-pipelines.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..b2d53e6 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,32 @@ +trigger: + - azure-pipelines + +pool: + vmImage: "ubuntu-latest" + +variables: + azureSubscription: "azureSubscription" + acrConnection: "acrConnection" + acrLoginServer: "acrincludia2771.azurecr.io" + webAppName: "app-includia-iot-2771" + buildContext: "." + dockerfilePath: "Dockerfile" + +steps: + - task: Docker@2 + displayName: "Build & Push IoT" + inputs: + containerRegistry: "$(acrConnection)" + repository: "$(webAppName)" + command: "buildAndPush" + Dockerfile: "$(dockerfilePath)" + buildContext: "$(buildContext)" + tags: "latest" + + - task: AzureWebAppContainer@1 + displayName: "Deploy IoT to Azure" + inputs: + azureSubscription: "$(azureSubscription)" + appName: "$(webAppName)" + containers: "$(acrLoginServer)/$(webAppName):latest" + appSettings: '-GEMINI_API_KEY "$(GOOGLE_API_KEY)"' From 1b50a2c3f3e03cfa67401b14b01cd149376f5f7b Mon Sep 17 00:00:00 2001 From: "Luiz Eduardo Da Silva P." <161588700+Lu1zEdu@users.noreply.github.com> Date: Thu, 20 Nov 2025 19:45:00 -0300 Subject: [PATCH 2/3] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 80 +++++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 24 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b2d53e6..c91f3ed 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -2,31 +2,63 @@ trigger: - azure-pipelines pool: - vmImage: "ubuntu-latest" + vmImage: 'ubuntu-latest' variables: - azureSubscription: "azureSubscription" - acrConnection: "acrConnection" - acrLoginServer: "acrincludia2771.azurecr.io" - webAppName: "app-includia-iot-2771" - buildContext: "." - dockerfilePath: "Dockerfile" + projectRoot: '.' + azureSubscription: 'azureSubscription' + acrConnection: 'acrConnection' + acrLoginServer: 'acrincludia2771.azurecr.io' + webAppName: 'app-includia-iot-2771' + imageName: 'includia-api' + tag: '$(Build.BuildId)' -steps: - - task: Docker@2 - displayName: "Build & Push IoT" - inputs: - containerRegistry: "$(acrConnection)" - repository: "$(webAppName)" - command: "buildAndPush" - Dockerfile: "$(dockerfilePath)" - buildContext: "$(buildContext)" - tags: "latest" +stages: +- stage: Build + displayName: Build and Test + jobs: + - job: Build + displayName: Build, Test and Push + steps: + + - task: DotNetCoreCLI@2 + displayName: 'Run Unit Tests' + inputs: + command: 'test' + projects: '$(projectRoot)/**/*.Tests.csproj' + arguments: '--configuration Release --logger trx --collect "Code coverage"' + publishTestResults: true - - task: AzureWebAppContainer@1 - displayName: "Deploy IoT to Azure" - inputs: - azureSubscription: "$(azureSubscription)" - appName: "$(webAppName)" - containers: "$(acrLoginServer)/$(webAppName):latest" - appSettings: '-GEMINI_API_KEY "$(GOOGLE_API_KEY)"' + - task: Docker@2 + displayName: 'Login to ACR' + inputs: + command: login + containerRegistry: $(acrConnection) + + - task: Docker@2 + displayName: 'Build and Push Docker Image' + inputs: + command: buildAndPush + repository: $(imageName) + dockerfile: '$(projectRoot)/Dockerfile' + buildContext: '$(projectRoot)' + containerRegistry: $(acrConnection) + tags: | + $(tag) + latest + +- stage: Deploy + displayName: Deploy to Azure + dependsOn: Build + condition: succeeded() + jobs: + - job: Deploy + displayName: Deploy to Web App Container + steps: + - task: AzureWebAppContainer@1 + displayName: 'Azure Web App Deploy' + inputs: + azureSubscription: $(azureSubscription) + appName: $(webAppName) + containers: '$(acrLoginServer)/$(imageName):$(tag)' + appSettings: '-ConnectionStrings__OracleDb "$(ORACLE_DB)" -ConnectionStrings__MongoDb "$(MONGO_DB)" -Jwt__Key "$(JWT_KEY)"' \ No newline at end of file From e3e5ceadfef1470288d163b1234f8f6022704a8a Mon Sep 17 00:00:00 2001 From: "Luiz Eduardo Da Silva P." <161588700+Lu1zEdu@users.noreply.github.com> Date: Thu, 20 Nov 2025 19:53:47 -0300 Subject: [PATCH 3/3] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c91f3ed..d125976 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,6 +12,8 @@ variables: webAppName: 'app-includia-iot-2771' imageName: 'includia-api' tag: '$(Build.BuildId)' + buildContext: '.' + dockerfilePath: 'Dockerfile' stages: - stage: Build