internal virtual void PolicizePublicStorageInfo(AuditModelType model, ProxyResource policy) { dynamic dynamicPolicy = (dynamic)policy; dynamicPolicy.StorageAccountAccessKey = AzureCommunicator.RetrieveStorageKeysAsync( model.StorageAccountResourceId).GetAwaiter().GetResult()[GetStorageKeyKind(model) == StorageKeyKind.Secondary ? StorageKeyKind.Secondary : StorageKeyKind.Primary]; }
private void PolicizeStorageInfo(ServerAuditModel model, dynamic policy) { ExtractStorageAccountProperties(model.StorageAccountResourceId, out string storageAccountName, out Guid storageAccountSubscriptionId); string storageEndpointSuffix = Context.Environment.GetEndpoint(AzureEnvironment.Endpoint.StorageEndpointSuffix); policy.StorageEndpoint = GetStorageAccountEndpoint(storageAccountName, storageEndpointSuffix); policy.StorageAccountAccessKey = AzureCommunicator.RetrieveStorageKeysAsync(model.StorageAccountResourceId).GetAwaiter().GetResult()[model.StorageKeyType]; policy.IsStorageSecondaryKeyInUse = model.StorageKeyType == StorageKeyKind.Secondary; policy.StorageAccountSubscriptionId = storageAccountSubscriptionId; if (model.RetentionInDays != null) { policy.RetentionDays = (int)model.RetentionInDays; } }
private void PolicizeStorageInfo(ServerAuditModel model, dynamic policy) { ExtractStorageAccountProperties(model.StorageAccountResourceId, out string storageAccountName, out Guid storageAccountSubscriptionId); policy.StorageEndpoint = GetStorageAccountEndpoint(storageAccountName); policy.StorageAccountSubscriptionId = storageAccountSubscriptionId; if (AzureCommunicator.IsStorageAccountInVNet(model.StorageAccountResourceId)) { Guid?principalId = Communicator.AssignServerIdentity(model.ResourceGroupName, model.ServerName); AzureCommunicator.AssignRoleForServerIdentityOnStorage(model.StorageAccountResourceId, principalId.Value, RoleAssignmentId); } else { policy.IsStorageSecondaryKeyInUse = model.StorageKeyType == StorageKeyKind.Secondary; policy.StorageAccountAccessKey = AzureCommunicator.RetrieveStorageKeysAsync(model.StorageAccountResourceId).GetAwaiter().GetResult()[model.StorageKeyType]; } if (model.RetentionInDays != null) { policy.RetentionDays = (int)model.RetentionInDays; } }