Skip to content

Commit f015eec

Browse files
committed
feat: [DTOSS-12154] disabled shared access key for storage account and enabled use managed identity for storage account
1 parent 743ebcc commit f015eec

24 files changed

Lines changed: 198 additions & 187 deletions

File tree

.github/workflows/stage-3-build-images-devtest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
with:
6666
repository: NHSDigital/dtos-devops-templates
6767
path: templates
68-
ref: main
68+
ref: feat/DTOSS-12154-disable-sas
6969

7070
- name: Determine which Docker container(s) to build
7171
id: get-function-names

application/CohortManager/src/Functions/CaasIntegration/RetrieveMeshFile/RetrieveMeshFile.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class RetrieveMeshFile
2020

2121
private readonly IMeshToBlobTransferHandler _meshToBlobTransferHandler;
2222
private readonly string _mailboxId;
23-
private readonly string _blobConnectionString;
23+
private Uri _blobServiceUri;
2424
private readonly IBlobStorageHelper _blobStorageHelper;
2525
private readonly RetrieveMeshFileConfig _config;
2626
private const string NextHandShakeTimeConfigKey = "NextHandShakeTime";
@@ -33,7 +33,7 @@ public RetrieveMeshFile(ILogger<RetrieveMeshFile> logger, IMeshToBlobTransferHan
3333
_blobStorageHelper = blobStorageHelper;
3434
_mailboxId = options.Value.BSSMailBox;
3535
_config = options.Value;
36-
_blobConnectionString = _config.caasfolder_STORAGE;
36+
_blobServiceUri = new Uri(_config.nemsmeshfolder_STORAGE__blobServiceUri);
3737
}
3838
/// <summary>
3939
/// This function polls the MESH Mailbox every 5 minutes, if there is a file posted to the mailbox.
@@ -51,7 +51,7 @@ public async Task RunAsync([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer)
5151
try
5252
{
5353
var shouldExecuteHandShake = await ShouldExecuteHandShake();
54-
var result = await _meshToBlobTransferHandler.MoveFilesFromMeshToBlob(messageFilter, fileNameFunction, _mailboxId, _blobConnectionString, "inbound", shouldExecuteHandShake);
54+
var result = await _meshToBlobTransferHandler.MoveFilesFromMeshToBlob(messageFilter, fileNameFunction, _mailboxId, _blobServiceUri, "inbound", shouldExecuteHandShake);
5555

5656
if (!result)
5757
{
@@ -74,7 +74,7 @@ private async Task<bool> ShouldExecuteHandShake()
7474

7575
Dictionary<string, string> configValues;
7676
TimeSpan handShakeInterval = new TimeSpan(0, 23, 54, 0);
77-
var meshState = await _blobStorageHelper.GetFileFromBlobStorage(_blobConnectionString, "config", ConfigFileName);
77+
var meshState = await _blobStorageHelper.GetFileFromBlobStorage(_blobServiceUri, "config", ConfigFileName);
7878
if (meshState == null)
7979
{
8080

@@ -140,7 +140,7 @@ private async Task<bool> SetConfigState(Dictionary<string, string> state)
140140
using (var stream = GenerateStreamFromString(jsonString))
141141
{
142142
var blobFile = new BlobFile(stream, ConfigFileName);
143-
var result = await _blobStorageHelper.UploadFileToBlobStorage(_blobConnectionString, "config", blobFile, true);
143+
var result = await _blobStorageHelper.UploadFileToBlobStorage(_blobServiceUri, "config", blobFile, true);
144144
return result;
145145
}
146146
}

application/CohortManager/src/Functions/CaasIntegration/RetrieveMeshFile/RetrieveMeshFileConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class RetrieveMeshFileConfig
1515
public string? MeshKeyName { get; set; }
1616
public string KeyVaultConnectionString { get; set; }
1717
[Required]
18-
public string caasfolder_STORAGE { get; set; }
18+
public string nemsmeshfolder_STORAGE__blobServiceUri { get; set; }
1919
public string? ServerSideCerts { get; set; }
2020
public string? MeshCertName { get; set; }
2121
public bool? BypassServerCertificateValidation { get; set; }

application/CohortManager/src/Functions/CaasIntegration/receiveCaasFile/ProcessFileClasses/CopyFailedBatchToBlob.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public async Task<bool> writeBatchToBlob(string jsonFromBatch, InvalidOperationE
2929
{
3030
// we do this so that we do not have files with the same names either failing to be added or over writing another failed batch
3131
var blobFile = new BlobFile(stream, $"failedBatch-{Guid.NewGuid()}.json");
32-
var copied = await _blobStorageHelper.UploadFileToBlobStorage(_config.caasfolder_STORAGE, "failed-batch", blobFile);
32+
var copied = await _blobStorageHelper.UploadFileToBlobStorage(new Uri(_config.caasfolder_STORAGE__blobServiceUri), "failed-batch", blobFile);
3333

3434
if (copied)
3535
{

application/CohortManager/src/Functions/CaasIntegration/receiveCaasFile/receiveCaasFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public async Task Run([BlobTrigger("inbound/{name}", Connection = "caasfolder_ST
100100
{
101101
_logger.LogError(ex, "There was a system exception in receive-caas-file");
102102
await _exceptionHandler.CreateSystemExceptionLogFromNhsNumber(ex, "", name, screeningName, "");
103-
await _blobStorageHelper.CopyFileToPoisonAsync(_config.caasfolder_STORAGE, name, _config.inboundBlobName);
103+
await _blobStorageHelper.CopyFileToPoisonAsync(new Uri(_config.caasfolder_STORAGE__blobServiceUri), name, _config.inboundBlobName);
104104
}
105105
finally
106106
{

application/CohortManager/src/Functions/CaasIntegration/receiveCaasFile/receiveCaasFileConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ReceiveCaasFileConfig
1616
[Required]
1717
public int maxNumberOfChecks { get; set; }
1818
[Required]
19-
public string caasfolder_STORAGE { get; set; }
19+
public string caasfolder_STORAGE__blobServiceUri { get; set; }
2020
[Required]
2121
public string inboundBlobName { get; set; }
2222
[Required]

application/CohortManager/src/Functions/NemsSubscriptionService/NemsMeshRetrieval/NemsMeshRetrieval.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class NemsMeshRetrieval
2020

2121
private readonly IMeshToBlobTransferHandler _meshToBlobTransferHandler;
2222
private readonly string _mailboxId;
23-
private readonly string _blobConnectionString;
23+
private readonly Uri _blobServiceUri;
2424
private readonly IBlobStorageHelper _blobStorageHelper;
2525
private readonly NemsMeshRetrievalConfig _config;
2626
private const string NextHandShakeTimeConfigKey = "NextHandShakeTime";
@@ -33,7 +33,7 @@ public NemsMeshRetrieval(ILogger<NemsMeshRetrieval> logger, IMeshToBlobTransferH
3333
_blobStorageHelper = blobStorageHelper;
3434
_mailboxId = options.Value.NemsMeshMailBox;
3535
_config = options.Value;
36-
_blobConnectionString = _config.nemsmeshfolder_STORAGE;
36+
_blobServiceUri = new Uri(_config.nemsmeshfolder_STORAGE__blobServiceUri);
3737
}
3838
/// <summary>
3939
/// This function polls the MESH Mailbox every 5 minutes, if there is a file posted to the mailbox.
@@ -51,7 +51,7 @@ public async Task RunAsync([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer)
5151
try
5252
{
5353
var shouldExecuteHandShake = await ShouldExecuteHandShake();
54-
var result = await _meshToBlobTransferHandler.MoveFilesFromMeshToBlob(messageFilter, fileNameFunction, _mailboxId, _blobConnectionString, _config.NemsMeshInboundContainer, shouldExecuteHandShake);
54+
var result = await _meshToBlobTransferHandler.MoveFilesFromMeshToBlob(messageFilter, fileNameFunction, _mailboxId, _blobServiceUri, _config.NemsMeshInboundContainer, shouldExecuteHandShake);
5555

5656
if (!result)
5757
{
@@ -74,7 +74,7 @@ private async Task<bool> ShouldExecuteHandShake()
7474

7575
Dictionary<string, string> configValues;
7676
TimeSpan handShakeInterval = new TimeSpan(0, 23, 54, 0);
77-
var meshState = await _blobStorageHelper.GetFileFromBlobStorage(_blobConnectionString, _config.NemsMeshConfigContainer, ConfigFileName);
77+
var meshState = await _blobStorageHelper.GetFileFromBlobStorage(_blobServiceUri, _config.NemsMeshConfigContainer, ConfigFileName);
7878
if (meshState == null)
7979
{
8080

@@ -140,7 +140,7 @@ private async Task<bool> SetConfigState(Dictionary<string, string> state)
140140
using (var stream = GenerateStreamFromString(jsonString))
141141
{
142142
var blobFile = new BlobFile(stream, ConfigFileName);
143-
var result = await _blobStorageHelper.UploadFileToBlobStorage(_blobConnectionString, _config.NemsMeshConfigContainer, blobFile, true);
143+
var result = await _blobStorageHelper.UploadFileToBlobStorage(_blobServiceUri, _config.NemsMeshConfigContainer, blobFile, true);
144144
return result;
145145
}
146146
}

application/CohortManager/src/Functions/NemsSubscriptionService/NemsMeshRetrieval/NemsMeshRetrievalConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class NemsMeshRetrievalConfig
1515
public string NemsMeshKeyName {get; set;}
1616
public string KeyVaultConnectionString {get; set;}
1717
[Required]
18-
public string nemsmeshfolder_STORAGE {get; set;}
18+
public string nemsmeshfolder_STORAGE__blobServiceUri { get; set;}
1919
public string NemsMeshInboundContainer { get; set; } = "nems-updates";
2020
public string NemsMeshConfigContainer { get; set; } = "nems-config";
2121
public string NemsMeshServerSideCerts { get; set; }

application/CohortManager/src/Functions/NemsSubscriptionService/ProcessNemsUpdate/ProcessNemsUpdate.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace NHS.Screening.ProcessNemsUpdate;
1+
namespace NHS.Screening.ProcessNemsUpdate;
22

33
using System.Collections.Concurrent;
44
using System.Collections.Specialized;
@@ -119,7 +119,7 @@ public async Task Run([BlobTrigger("nems-updates/{name}", Connection = "nemsmesh
119119

120120
private async Task CopyToPoisonContainer(string fileName)
121121
{
122-
await _blobStorageHelper.CopyFileToPoisonAsync(_config.nemsmeshfolder_STORAGE, fileName, _config.NemsMessages, _config.NemsPoisonContainer, addTimestamp: true);
122+
await _blobStorageHelper.CopyFileToPoisonAsync(new Uri(_config.nemsmeshfolder_STORAGE__blobServiceUri), fileName, _config.NemsMessages, _config.NemsPoisonContainer, addTimestamp: true);
123123
_logger.LogInformation("Copied failed NEMS file {FileName} to poison container with timestamp.", fileName);
124124
}
125125

application/CohortManager/src/Functions/NemsSubscriptionService/ProcessNemsUpdate/ProcessNemsUpdateConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ public class ProcessNemsUpdateConfig
2323
public required string DemographicDataServiceURL { get; set; }
2424

2525
[Required]
26-
public required string nemsmeshfolder_STORAGE { get; set; }
26+
public required string nemsmeshfolder_STORAGE__blobServiceUri { get; set; }
2727
public string NemsPoisonContainer { get; set; } = "nems-poison";
2828
}

0 commit comments

Comments
 (0)