diff --git a/src/Utils/NetworkUtility.ts b/src/Utils/NetworkUtility.ts index d7c4ab1cc..70fb78c1b 100644 --- a/src/Utils/NetworkUtility.ts +++ b/src/Utils/NetworkUtility.ts @@ -11,30 +11,34 @@ const PortalIPs: { [key: string]: string[] } = { }; export const doNetworkSettingsAllowDataExplorerAccess = (): boolean => { - const accountProperties = userContext.databaseAccount?.properties; + if (userContext.apiType === "Cassandra" || userContext.apiType === "Mongo") { + const accountProperties = userContext.databaseAccount?.properties; - if (!accountProperties) { - return false; - } - - // public network access is disabled - if (accountProperties.publicNetworkAccess !== "Enabled") { - return false; - } - - const ipRules = accountProperties.ipRules; - // public network access is set to "All networks" - if (ipRules.length === 0) { - return true; - } - - const portalIPs = PortalIPs[userContext.portalEnv]; - let numberOfMatches = 0; - ipRules.forEach((ipRule) => { - if (portalIPs.indexOf(ipRule.ipAddressOrRange) !== -1) { - numberOfMatches++; + if (!accountProperties) { + return false; } - }); - return numberOfMatches === portalIPs.length; + // public network access is disabled + if (accountProperties.publicNetworkAccess !== "Enabled") { + return false; + } + + const ipRules = accountProperties.ipRules; + // public network access is set to "All networks" + if (ipRules.length === 0) { + return true; + } + + const portalIPs = PortalIPs[userContext.portalEnv]; + let numberOfMatches = 0; + ipRules.forEach((ipRule) => { + if (portalIPs.indexOf(ipRule.ipAddressOrRange) !== -1) { + numberOfMatches++; + } + }); + + return numberOfMatches === portalIPs.length; + } + + return true; };