public async Task CheckTableAccessActivity()

in src/ApiForFhirMigrationTool.Function/CheckAccess.cs [73:105]


        public async Task<string> CheckTableAccessActivity([ActivityTrigger] object input, FunctionContext executionContext)
        {
            ILogger logger = executionContext.GetLogger(nameof(CheckTableAccessActivity));
            logger.LogInformation("Performing storage account access check.");

            string storageAccountName = _options.StagingStorageAccountName;
            JObject checkResult = new JObject();

            try
            {
                string tableServiceUri = _options.StagingStorageUri;
                TableServiceClient tableServiceClient = new TableServiceClient(new Uri(tableServiceUri), new DefaultAzureCredential());

                await foreach (TableItem table in tableServiceClient.QueryAsync())
                {
                    checkResult["Status"] = "Success";
                    checkResult["Message"] = $"Successfully accessed storage account '{storageAccountName}'.";
                    logger.LogInformation($"Status for accessing storage account: {checkResult["Status"]}");
                    return checkResult.ToString();
                }

                checkResult["Status"] = "Success";
                checkResult["Message"] = $"Successfully accessed storage account '{storageAccountName}'";
            }
            catch (Exception ex)
            {
                logger.LogError($"Failed to access the storage account: {ex.Message}");
                checkResult["Status"] = "Failed";
                checkResult["Message"] = $"Failed to access the storage account: {ex.Message}";
            }
            logger.LogInformation($"Status for accessing storage account: {checkResult["Status"]}");
            return checkResult.ToString();
        }