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];
        }
        protected override void PolicizeAuditModel(DatabaseAuditModel model, ProxyResource policy)
        {
            dynamic dynamicPolicy = (dynamic)policy;

            base.PolicizeAuditModel(model, policy);

            dynamicPolicy.AuditActionsAndGroups = ExtractAuditActionsAndGroups(model.AuditActionGroup, model.AuditAction);
        }
        internal override void PolicizePublicStorageInfo(AuditModelType model, ProxyResource policy)
        {
            dynamic dynamicPolicy = (dynamic)policy;

            base.PolicizePublicStorageInfo(model, policy);

            dynamicPolicy.IsStorageSecondaryKeyInUse = model.StorageKeyType == StorageKeyKind.Secondary;
        }
        internal override void PolicizeStorageInfo(AuditModelType model, ProxyResource policy)
        {
            dynamic dynamicPolicy = (dynamic)policy;

            base.PolicizeStorageInfo(model, policy);

            if (model.RetentionInDays != null)
            {
                dynamicPolicy.RetentionDays = (int)model.RetentionInDays;
            }
        }
        protected virtual void PolicizeAuditModel(AuditModelType model, ProxyResource policy)
        {
            dynamic dynamicPolicy = (dynamic)policy;

            dynamicPolicy.State = model.BlobStorageTargetState == AuditStateType.Enabled ||
                                  model.EventHubTargetState == AuditStateType.Enabled ||
                                  model.LogAnalyticsTargetState == AuditStateType.Enabled ?
                                  BlobAuditingPolicyState.Enabled : BlobAuditingPolicyState.Disabled;

            dynamicPolicy.IsAzureMonitorTargetEnabled = model.IsAzureMonitorTargetEnabled;

            if (model.BlobStorageTargetState == AuditStateType.Enabled)
            {
                PolicizeStorageInfo(model, policy);
            }
        }
        internal virtual void PolicizeStorageInfo(AuditModelType model, ProxyResource policy)
        {
            dynamic dynamicPolicy = (dynamic)policy;

            ExtractStorageAccountProperties(model.StorageAccountResourceId, out string storageAccountName, out Guid storageAccountSubscriptionId);

            dynamicPolicy.StorageEndpoint = GetStorageAccountEndpoint(storageAccountName);
            dynamicPolicy.StorageAccountSubscriptionId = storageAccountSubscriptionId;

            if (AzureCommunicator.IsStorageAccountInVNet(model.StorageAccountResourceId))
            {
                Guid?principalId = Communicator.AssignServerIdentityIfNotAssigned(model.ResourceGroupName, model.ServerName);
                AzureCommunicator.AssignRoleForServerIdentityOnStorageIfNotAssigned(model.StorageAccountResourceId, principalId.Value, RoleAssignmentId);
            }
            else
            {
                PolicizePublicStorageInfo(model, policy);
            }
        }