Skip to content

Commit d8db402

Browse files
CeredronCeredron
andauthored
Deployed storage accounts should be zrs, not lrs (#1754)
* Deployed storage accounts should be zrs, not lrs * Fix code that didnt make sense anymore * Fixed structure logging --------- Co-authored-by: Ceredron <roar.mjelde@digdir.no>
1 parent 937e02f commit d8db402

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

src/Altinn.Correspondence.Application/Helpers/AttachmentHelper.cs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,16 @@ private bool ShouldBypassMalwareScan(AttachmentEntity attachment)
111111

112112
public async Task<StorageProviderEntity> GetStorageProvider(AttachmentEntity attachment, bool bypassMalwareScan, CancellationToken cancellationToken)
113113
{
114-
ServiceOwnerEntity? serviceOwnerEntity = null;
115-
if (bypassMalwareScan)
114+
var serviceOwnerOrgCode = await resourceRegistryService.GetServiceOwnerOrgCode(attachment.ResourceId, cancellationToken);
115+
if (serviceOwnerOrgCode is null)
116116
{
117-
var serviceOwnerShortHand = attachment.ResourceId.Split('-')[0];
118-
serviceOwnerEntity = await serviceOwnerRepository.GetServiceOwnerByOrgCode(serviceOwnerShortHand.ToLower(), cancellationToken);
117+
logger.LogError("Could not find service owner for resource {resourceId}", attachment.ResourceId);
118+
return null;
119119
}
120-
else
121-
{
122-
var serviceOwnerOrgCode = await resourceRegistryService.GetServiceOwnerOrgCode(attachment.ResourceId, cancellationToken);
123-
if (serviceOwnerOrgCode is null)
124-
{
125-
logger.LogError("Could not find service owner for resource {resourceId}", attachment.ResourceId);
126-
return null;
127-
}
128-
serviceOwnerEntity = await serviceOwnerRepository.GetServiceOwnerByOrgCode(serviceOwnerOrgCode, cancellationToken);
129-
}
130-
if (serviceOwnerEntity == null)
120+
var serviceOwnerEntity = await serviceOwnerRepository.GetServiceOwnerByOrgCode(serviceOwnerOrgCode, cancellationToken);
121+
if (serviceOwnerEntity is null)
131122
{
132-
logger.LogError($"Could not find service owner entity for {attachment.ResourceId} in database");
123+
logger.LogError("Could not find service owner entity for {resourceId} in database", attachment.ResourceId);
133124
//return AttachmentErrors.ServiceOwnerNotFound; // Future PR will add service owner registry as requirement when we have ensured that existing service owners have been provisioned
134125
}
135126
return serviceOwnerEntity?.GetStorageProvider(bypassMalwareScan: bypassMalwareScan);

src/Altinn.Correspondence.Integrations/Azure/AzureResourceManagerService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public async Task DeployStorageAccount(ServiceOwnerEntity serviceOwnerEntity, bo
103103
var resourceGroup = await resourceGroupCollection.CreateOrUpdateAsync(WaitUntil.Completed, resourceGroupName, resourceGroupData, cancellationToken);
104104

105105
// Create or get the storage account
106-
var storageAccountData = new StorageAccountCreateOrUpdateContent(new StorageSku(StorageSkuName.StandardLrs), StorageKind.StorageV2, new AzureLocation(_resourceManagerOptions.Location));
106+
var storageAccountData = new StorageAccountCreateOrUpdateContent(new StorageSku(StorageSkuName.StandardZrs), StorageKind.StorageV2, new AzureLocation(_resourceManagerOptions.Location));
107107
storageAccountData.MinimumTlsVersion = "TLS1_2";
108108
storageAccountData.AllowSharedKeyAccess = false;
109109
foreach (var tag in GetServiceOwnerResourceGroupTags(serviceOwnerEntity))

0 commit comments

Comments
 (0)