diff --git a/.github/workflows/azure-webapps-java-war-prod.yml b/.github/workflows/azure-webapps-java-war-prod.yml new file mode 100644 index 0000000..246705a --- /dev/null +++ b/.github/workflows/azure-webapps-java-war-prod.yml @@ -0,0 +1,37 @@ +name: Java CI with Maven (Production) + +env: + AZURE_WEBAPP_NAME: scf-remote-storage-app + JAVA_VERSION: '11' + DISTRIBUTION: 'zulu' + +on: + push: + tags: + - '*' + +jobs: + build: + + runs-on: ubuntu-latest + environment: 'Production IZs - Stage' + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java version + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.DISTRIBUTION }} + cache: 'maven' + + - name: Build with Maven + run: mvn package + + - name: Azure WebApp + uses: Azure/webapps-deploy@v3 + with: + app-name: ${{ env.AZURE_WEBAPP_NAME }} + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_PROD }} + package: '*.war' \ No newline at end of file diff --git a/.github/workflows/azure-webapps-java-war-psb.yml b/.github/workflows/azure-webapps-java-war-psb.yml new file mode 100644 index 0000000..8778ddf --- /dev/null +++ b/.github/workflows/azure-webapps-java-war-psb.yml @@ -0,0 +1,36 @@ +name: Java CI with Maven (PSB) + +env: + AZURE_WEBAPP_NAME: scf-remote-storage-app-psb-iz + JAVA_VERSION: '11' + DISTRIBUTION: 'zulu' + +on: + push: + branches: [ "main"] + +jobs: + build: + + runs-on: ubuntu-latest + environment: 'PSB IZs - Stage' + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java version + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.DISTRIBUTION }} + cache: 'maven' + + - name: Build with Maven + run: mvn package + + - name: Azure WebApp + uses: Azure/webapps-deploy@v3 + with: + app-name: ${{ env.AZURE_WEBAPP_NAME }} + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_PSB }} + package: '*.war' \ No newline at end of file diff --git a/.github/workflows/main_scf-remote-storage-app(stage).yml b/.github/workflows/main_scf-remote-storage-app(stage).yml new file mode 100644 index 0000000..d4abf68 --- /dev/null +++ b/.github/workflows/main_scf-remote-storage-app(stage).yml @@ -0,0 +1,63 @@ +# 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 WAR app to Azure Web App - scf-remote-storage-app + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read #This is required for actions/checkout + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java version + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'microsoft' + + - name: Build with Maven + run: mvn clean install + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v4 + with: + name: java-app + path: '${{ github.workspace }}/target/*.war' + + deploy: + runs-on: ubuntu-latest + needs: build + permissions: + id-token: write #This is required for requesting the JWT + contents: read #This is required for actions/checkout + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v4 + with: + name: java-app + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_E30C62BC95864D02B791F844D34CABBA }} + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_83ABBDA0F7A3476486B300709D7A60AB }} + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_C34478ADAB84421D9E25B7C7B4B855A8 }} + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v3 + with: + app-name: 'scf-remote-storage-app' + slot-name: 'stage' + package: '*.war' + diff --git a/.gitignore b/.gitignore index 2786034..1196853 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +.idea +src/main/resources/conf.json +target # Maven target/ pom.xml.tag diff --git a/pom.xml b/pom.xml index 31bb2e3..786e816 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,16 @@ Alma Remote Storage App + + com.microsoft.azure + applicationinsights-web + 3.6.1 + + + com.microsoft.azure + applicationinsights-logging-log4j1_2 + 2.6.4 + com.sun.istack @@ -32,7 +42,7 @@ org.json json - 20180813 + 20231013 @@ -62,7 +72,7 @@ commons-io commons-io - 2.7 + 2.14.0 diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties index 81f6f00..009adc8 100644 --- a/src/main/resources/log4j.properties +++ b/src/main/resources/log4j.properties @@ -1,16 +1,22 @@ # Root logger option -log4j.rootLogger=INFO, stdout,file +log4j.rootLogger=DEBUG, stdout,file, AppInsightsAppender # Redirect log messages to console log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.EnhancedPatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss,SSS}{Etc/UTC} %tid %-5p %15.15c{1} %3.3L: %m %n +log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss,SSS}{America/New_York} %tid %-5p %15.15c{1} %3.3L: %m %n # Redirect log messages to a log file, support file rolling. log4j.appender.file=org.apache.log4j.DailyRollingFileAppender -log4j.appender.file.File=logs/application.log +log4j.appender.file.File=/mnt/AlmaRSA/logs/application.log log4j.appender.file.DatePattern='_'yyyy-MM-dd'.log' log4j.appender.file.layout=org.apache.log4j.EnhancedPatternLayout -log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS}{Etc/UTC} %tid %-5p %15.15c{1} %3.3L: %m %n \ No newline at end of file +log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS}{America/New_York} %tid %-5p %15.15c{1} %3.3L: %m %n + +# Application Insights Appender +log4j.appender.AppInsightsAppender=com.microsoft.applicationinsights.log4j.v1_2.ApplicationInsightsAppender +# Optional: Set a layout for the AppInsightsAppender if needed, though often not necessary +log4j.appender.AppInsightsAppender.layout=org.apache.log4j.EnhancedPatternLayout +log4j.appender.AppInsightsAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS}{America/New_York} %tid %-5p %15.15c{1} %3.3L: %m %n \ No newline at end of file