AzureBlobPayloadStorage implements ExternalPayloadStorage { @Override public ExternalStorageLocation getLocation(Operation operation, PayloadType payloadType, String path) { try { ExternalStorageLocation externalStorageLocation = new ExternalStorageLocation(); String objectKey; if (StringUtils.isNotBlank(path)) { objectKey = path; } else { objectKey = getObjectKey(payloadType); } externalStorageLocation.setPath(objectKey); BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(objectKey).getBlockBlobClient(); String blobUrl = Utility.urlDecode(blockBlobClient.getBlobUrl()); if (sasTokenCredential != null) { blobUrl = blobUrl + "?" + sasTokenCredential.getSasToken(); } else { BlobSasPermission blobSASPermission = new BlobSasPermission(); if (operation.equals(Operation.READ)) { blobSASPermission.setReadPermission(true); } else if (operation.equals(Operation.WRITE)) { blobSASPermission.setWritePermission(true); blobSASPermission.setCreatePermission(true); } BlobServiceSasSignatureValues blobServiceSasSignatureValues = new BlobServiceSasSignatureValues( OffsetDateTime.now(ZoneOffset.UTC).plusSeconds(expirationSec), blobSASPermission ); blobUrl = blobUrl + "?" + blockBlobClient.generateSas(blobServiceSasSignatureValues); } externalStorageLocation.setUri(blobUrl); return externalStorageLocation; } catch (BlobStorageException e) { String msg = "Error communicating with Azure"; logger.error(msg, e); throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, msg, e); } } @Inject  AzureBlobPayloadStorage(AzureBlobConfiguration config); @Override ExternalStorageLocation getLocation(Operation operation, PayloadType payloadType, String path); @Override void upload(String path, InputStream payload, long payloadSize); @Override InputStream download(String path);  }
@Test public void testGetLocationFixedPath() { testConfiguration.setConnectionString(azuriteConnectionString); AzureBlobPayloadStorage azureBlobPayloadStorage = new AzureBlobPayloadStorage(testConfiguration); ExternalStorageLocation externalStorageLocation = azureBlobPayloadStorage.getLocation(ExternalPayloadStorage.Operation.READ, ExternalPayloadStorage.PayloadType.WORKFLOW_INPUT, path); assertNotNull(externalStorageLocation); assertEquals(path, externalStorageLocation.getPath()); assertNotNull(externalStorageLocation.getUri()); }