diff --git a/.github/workflows/remote-cd-trigger-template.yml b/.github/workflows/remote-cd-trigger-template.yml index 9e3288f7f..06d9919db 100644 --- a/.github/workflows/remote-cd-trigger-template.yml +++ b/.github/workflows/remote-cd-trigger-template.yml @@ -39,8 +39,8 @@ jobs: owner: 'cdcent', repo: 'data-exchange-upload-devops', workflow_id: '${{ inputs.WORKFLOW }}', - ref: 'main', + ref: 'upload-291/bulk-file-upload-pipeline', inputs: { - DATA_EXCHANGE_UPLOAD_REF: '${{ inputs.REF }}' + DATA_EXCHANGE_UPLOAD_REF: 'ccampbell-test' } }) diff --git a/cosmos-sync-function-app/src/main/java/gov/cdc/ocio/cosmossync/FunctionJavaWrappers.java b/cosmos-sync-function-app/src/main/java/gov/cdc/ocio/cosmossync/FunctionJavaWrappers.java index ba38a5c2b..aae10d580 100644 --- a/cosmos-sync-function-app/src/main/java/gov/cdc/ocio/cosmossync/FunctionJavaWrappers.java +++ b/cosmos-sync-function-app/src/main/java/gov/cdc/ocio/cosmossync/FunctionJavaWrappers.java @@ -3,9 +3,22 @@ import com.microsoft.azure.functions.annotation.*; import com.microsoft.azure.functions.*; import gov.cdc.ocio.cosmossync.functions.CosmosSyncFunction; +import gov.cdc.ocio.cosmossync.functions.HealthCheckFunction; +import java.util.Optional; public class FunctionJavaWrappers { + @FunctionName("HealthCheck") + public HttpResponseMessage healthCheck( + @HttpTrigger( + name = "req", + methods = {HttpMethod.GET}, + route = "health", + authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage> request, + final ExecutionContext context) { + return new HealthCheckFunction().run(request, context); + } + @FunctionName("CosmosQueueProcessor") public void run( @QueueTrigger(name = "msg", diff --git a/cosmos-sync-function-app/src/main/kotlin/gov/cdc/ocio/cosmossync/functions/HealthCheckFunction.kt b/cosmos-sync-function-app/src/main/kotlin/gov/cdc/ocio/cosmossync/functions/HealthCheckFunction.kt new file mode 100644 index 000000000..060d08885 --- /dev/null +++ b/cosmos-sync-function-app/src/main/kotlin/gov/cdc/ocio/cosmossync/functions/HealthCheckFunction.kt @@ -0,0 +1,46 @@ +package gov.cdc.ocio.cosmossync.functions + +import com.azure.cosmos.models.CosmosQueryRequestOptions +import com.microsoft.azure.functions.ExecutionContext +import com.microsoft.azure.functions.HttpRequestMessage +import com.microsoft.azure.functions.HttpResponseMessage +import com.microsoft.azure.functions.HttpStatus +import gov.cdc.ocio.cosmossync.cosmos.CosmosClientManager +import gov.cdc.ocio.cosmossync.model.Item +import java.util.* +import java.util.logging.Logger + +class HealthCheckFunction { + + fun run( + request: HttpRequestMessage>, + context: ExecutionContext + ): HttpResponseMessage { + + try { + val cosmosClient = CosmosClientManager.getCosmosClient() + + val databaseName = System.getenv("CosmosDbDatabaseName") + val containerName = System.getenv("CosmosDbContainerName") + + val cosmosDB = cosmosClient.getDatabase(databaseName) + val container = cosmosDB.getContainer(containerName) + + val sqlQuery = "select * from $containerName t OFFSET 0 LIMIT 1" + val items = container.queryItems( + sqlQuery, CosmosQueryRequestOptions(), + Item::class.java + ) + + return request + .createResponseBuilder(HttpStatus.OK) + .build() + + } catch (ex: Throwable) { + + return request + .createResponseBuilder(HttpStatus.INTERNAL_SERVER_ERROR) + .build() + } + } +} \ No newline at end of file