|
| 1 | +--- |
| 2 | +title: "Azure connectivity" |
| 3 | +description: Explains the Azure connection options available in Azure Data Studio. |
| 4 | +author: erinstellato-ms |
| 5 | +ms.author: erinstellato |
| 6 | +ms.reviewer: maghan, randolphwest |
| 7 | +ms.date: 03/22/2023 |
| 8 | +ms.service: azure-data-studio |
| 9 | +ms.topic: "overview" |
| 10 | +--- |
| 11 | +# Azure Data Studio - Azure connectivity |
| 12 | + |
| 13 | +Azure Data Studio uses the Microsoft Authentication Library (MSAL) by default to acquire an access token from Azure Active Directory. The settings that apply to Azure authentication are discussed, along with commonly observed issues and their solutions. |
| 14 | + |
| 15 | +## Azure: Authentication library |
| 16 | + |
| 17 | +This setting controls the authentication library used by Azure Data Studio when adding an Azure account. Microsoft Authentication Library (MSAL) offers authentication and authorization services using standard-compliant implementations of OAuth 2.0 and OpenID Connect (OIDC) 1.0. Read more about [Microsoft Authentication Library (MSAL)](/azure/active-directory/develop/msal-overview). |
| 18 | + |
| 19 | +`Settings.json` |
| 20 | + |
| 21 | +```json |
| 22 | +"azure.authenticationLibrary": "MSAL" |
| 23 | +``` |
| 24 | + |
| 25 | +:::image type="content" source="media/azure-connectivity/authentication-library.png" alt-text="Screenshot of Azure authentication library."::: |
| 26 | + |
| 27 | +**ADAL (Active Directory Authentication Library)** is now deprecated, but is supported by Azure Data Studio as a fallback for any potential authentication issues with MSAL. |
| 28 | + |
| 29 | +> [!NOTE] |
| 30 | +> Switching the authentication library requires reloading Azure Data Studio. Existing Azure accounts are marked stale and users must re-authenticate with the selected library. |
| 31 | +
|
| 32 | +## Azure authentication method |
| 33 | + |
| 34 | +Azure Data Studio supports multi-factor authentication with Azure accounts using the following modes: |
| 35 | + |
| 36 | +- Using Code Grant authentication (enabled by default) |
| 37 | +- Using Device Code authentication |
| 38 | + |
| 39 | +### Accounts > Azure > Auth: Code Grant |
| 40 | + |
| 41 | +`Settings.json` |
| 42 | + |
| 43 | +```json |
| 44 | +"accounts.azure.auth.codeGrant": true |
| 45 | +``` |
| 46 | + |
| 47 | +:::image type="content" source="media/azure-connectivity/code-grant.png" alt-text="Screenshot of Azure authentication Code Grant option."::: |
| 48 | + |
| 49 | +When **Code Grant method** is checked, users are prompted to authenticate with browser based authentication. This option is enabled by default. |
| 50 | + |
| 51 | +### Accounts > Azure > Auth: Device Code |
| 52 | + |
| 53 | +`Settings.json` |
| 54 | + |
| 55 | +```json |
| 56 | +"accounts.azure.auth.deviceCode": true |
| 57 | +``` |
| 58 | + |
| 59 | +:::image type="content" source="media/azure-connectivity/device-code.png" alt-text="Screenshot of Azure authentication Device Code option."::: |
| 60 | + |
| 61 | +When **Device Code method** is enabled, users are provided with a code and a URL to enter which can then be used to sign in. |
| 62 | + |
| 63 | +When both options are checked, users are prompted to select one of the two authentication modes when adding an Azure account. |
| 64 | + |
| 65 | +## Azure account configuration |
| 66 | + |
| 67 | +Azure Data Studio supports Azure Active Directory (Azure AD) authentication with National clouds. **Azure Public Cloud** is enabled by default, but users can enable other national clouds as needed: |
| 68 | + |
| 69 | +`Settings.json` |
| 70 | + |
| 71 | +```json |
| 72 | +"accounts.azure.cloud.enableChinaCloud": false, |
| 73 | +"accounts.azure.cloud.enablePublicCloud": true, |
| 74 | +"accounts.azure.cloud.enableUsGovCloud": false |
| 75 | +``` |
| 76 | + |
| 77 | +:::image type="content" source="media/azure-connectivity/national-clouds.png" alt-text="Screenshot of Azure authentication National Clouds."::: |
| 78 | + |
| 79 | +> [!NOTE] |
| 80 | +> Only one National Cloud can be enabled in a session. |
| 81 | +
|
| 82 | +## Azure resource configuration |
| 83 | + |
| 84 | +These settings apply filters on Azure resources and tenants. |
| 85 | + |
| 86 | +- Resource Config filter: Applies inclusion filter to resources that should be displayed. |
| 87 | +- Tenant Config filter: Applies exclusion filter to tenants that should be ignored. |
| 88 | + |
| 89 | +`Settings.json` |
| 90 | + |
| 91 | +```json |
| 92 | +"azure.resource.config.filter": [], |
| 93 | +"azure.tenant.config.filter": [ |
| 94 | + "313b5f9e-9b92-414c-8d87-a317e42d0222" |
| 95 | +] |
| 96 | +``` |
| 97 | + |
| 98 | +:::image type="content" source="media/azure-connectivity/resource-config.png" alt-text="Screenshot of Azure authentication resource configuration options."::: |
| 99 | + |
| 100 | +## Proxy setup for Azure authentication |
| 101 | + |
| 102 | +If using Azure Data Studio (ADS) behind a proxy, users must specify proxy settings for ADS to communicate with external endpoints. There are two ways to provide proxy settings for ADS to use: |
| 103 | + |
| 104 | +- Setting proxy configuration in the Azure Data Studio (**Settings > Http: Proxy Settings**), or |
| 105 | +- Setting environment variables for proxy configuration. |
| 106 | + |
| 107 | +Azure Data Studio settings take precedence over environment variables. |
| 108 | + |
| 109 | +### Azure Data Studio proxy settings |
| 110 | + |
| 111 | +The following settings are available in Azure Data Studio: |
| 112 | + |
| 113 | +`Settings.json` |
| 114 | + |
| 115 | +```json |
| 116 | +"http.proxy": "https://userName@fqdn:yourPassword@yourProxyURL.com:8080", |
| 117 | +"http.proxyStrictSSL": true, |
| 118 | +"http.proxyAuthorization": "", |
| 119 | +"http.proxySupport" : "override" |
| 120 | +``` |
| 121 | + |
| 122 | +:::image type="content" source="media/azure-connectivity/proxy-settings.png" alt-text="Screenshot of Azure authentication proxy settings."::: |
| 123 | + |
| 124 | +### Supported environment variables for proxy |
| 125 | + |
| 126 | +- `'HTTP_PROXY': 'http://userName@fqdn:yourPassword@yourProxyURL.com:8080'` |
| 127 | +- `'HTTPS_PROXY': 'https://userName@fqdn:yourPassword@yourProxyURL.com:8080'` |
| 128 | + |
| 129 | +### Allowlist URLs |
| 130 | + |
| 131 | +In a proxy environment, user applications may need to allow specific domains used by Azure Data Studio. Hostnames through which you may need or want to allow communication are: |
| 132 | + |
| 133 | +**Azure Public** |
| 134 | + |
| 135 | +- https://management.azure.com |
| 136 | +- https://login.microsoftonline.com/ |
| 137 | + |
| 138 | +**Azure (US Government)** |
| 139 | + |
| 140 | +- https://management.core.usgovcloudapi.net/ |
| 141 | +- https://login.microsoftonline.us/ |
| 142 | + |
| 143 | +**Azure (China)** |
| 144 | + |
| 145 | +- https://management.core.chinacloudapi.cn/ |
| 146 | +- https://login.partner.microsoftonline.cn/ |
| 147 | + |
| 148 | +The URLs to allow can sometimes vary on a case-by-case basis. In order to verify you aren't blocking any URLs from going through, go to **Help > Toggle Developer Tools** and select the **Network** tab. Any URLs that are blocked are listed, and you may need to allow those URLs to successfully add your account. |
| 149 | + |
| 150 | +## Common authentication issues |
| 151 | + |
| 152 | +Possible issues and solutions when adding an Azure account are discussed. |
| 153 | + |
| 154 | +### Issue: SSL Error on localhost page (ERR_SSL_PROTOCOL_ERROR) |
| 155 | + |
| 156 | +Users may see an SSL error when signing in to their account. This flow opens an external web page to `localhost`, typically prompting users to sign in via the standard Microsoft authentication prompts. The URL for this page looks similar to `http://localhost:50055/signin?nonce=...` |
| 157 | + |
| 158 | +Some browsers may be set up to automatically redirect all `http` links to `https`, which breaks this process as the local server serving the web page doesn't support https. If the link in the address bar starts with `https`, then you get an SSL error and the page can't load. In that case, the workarounds listed here may address the issue. |
| 159 | + |
| 160 | +**Change URL to http** |
| 161 | + |
| 162 | +First, manually change the URL from `https://` to `http://`. The browser may change it back to https, in which case it's necessary to try another option. |
| 163 | + |
| 164 | +**Disable HSTS (HTTP Strict Transport Security)** |
| 165 | + |
| 166 | +For Edge/Chrome browsers, you can disable [HSTS](https://www.chromium.org/hsts/) for localhost. |
| 167 | + |
| 168 | +1. Open Edge/Chrome, and in the address bar, type `edge://net-internals/#hsts` (or `chrome://net-internals/#hsts` for Chrome). |
| 169 | +1. Scroll to the bottom of the page and in the `Delete domain security policies` section, enter `localhost` and press `Delete`. |
| 170 | + |
| 171 | +Once that is complete, you should be able to sign in, and not have the browser redirect your `localhost` links automatically to `https`. |
| 172 | + |
| 173 | +### Issue: Unable to add account behind a proxy |
| 174 | + |
| 175 | +If the user application is running in an environment behind a proxy, user authentication may not complete, and these steps can be used to resolve the issue. |
| 176 | + |
| 177 | +1. Recheck environment variables and **http.proxy** settings in ADS. If the proxy requires user authentication, providing a username/password in **http.proxy** URL can resolve authentication issues; otherwise, ADS can't read logged-in user credentials. Alternatively, running ADS as a different user can be attempted, as it may help resolve Authentication issues with Proxy. However, the latter only works for some scenarios. |
| 178 | + |
| 179 | +1. The URLs to allow can vary on a case-by-case basis. To verify you aren't blocking any URLs from going through, go to **Help > Toggle Developer Tools** and select the **Network** tab. Here you see any URLs that are getting blocked that you may need to allow to add your account successfully. |
| 180 | + |
| 181 | +1. Uncheck **Http: Proxy Strict SSL**. It's possible that proxy certificate isn't verifiable against the list of trusted CAs. Disabling Strict SSL can rule out the proxy certificate as an issue. |
| 182 | + |
| 183 | +**To conclude:** |
| 184 | + |
| 185 | +As a cross-platform application, ADS proxy resolution fetches the proxy from either setting within the application, or through environment variables. The aim is to avoid interaction with system settings, which can vary significantly on different operating systems. |
| 186 | + |
| 187 | +## Capture logs for Azure authentication |
| 188 | + |
| 189 | +Azure Data Studio captures Error events for Azure account activity by default. To enable more detailed traces, users can modify these settings: |
| 190 | + |
| 191 | +### Azure: Logging level |
| 192 | + |
| 193 | +This setting configures the logging level for information from Azure core that can be captured in Azure Data Studio. Change it to *Verbose* or *All* to capture detailed logs that can be useful to diagnose authentication failures. For more information, see [Debug Trace Logging](https://github.com/microsoft/azuredatastudio/wiki/Debug-Trace-Logging) to learn how to capture logging information. |
| 194 | + |
| 195 | +`Settings.json` |
| 196 | + |
| 197 | +```json |
| 198 | +"azure.loggingLevel": "Verbose" |
| 199 | +``` |
| 200 | + |
| 201 | +:::image type="content" source="media/azure-connectivity/logging-level.png" alt-text="Screenshot of Azure authentication logging Level configuration."::: |
| 202 | + |
| 203 | +### Azure: PII logging |
| 204 | + |
| 205 | +Users can enable PII (Personally Identifiable Information) logging for local testing and debugging purposes. This setting enables more thorough logging of the authentication process, but may contain sensitive information such as access tokens or user IDs when authenticating with Azure. Because this logging captures sensitive information, it's recommended to: |
| 206 | + |
| 207 | +- Not share these logs with anyone else, especially when adding logs to GitHub issues |
| 208 | +- Disable the setting once the necessary information has been collected |
| 209 | +- Delete the log files once the setting has been disabled |
| 210 | + |
| 211 | +`Settings.json` |
| 212 | + |
| 213 | +```json |
| 214 | +"azure.piiLogging": true |
| 215 | +``` |
| 216 | + |
| 217 | +:::image type="content" source="media/azure-connectivity/pii-logging.png" alt-text="Screenshot of Azure authentication PII logging option."::: |
| 218 | + |
| 219 | +## Azure: No system keychain |
| 220 | + |
| 221 | +This setting disables system keychain integration to prevent repeated keychain access prompts on macOS. User Credentials are alternatively stored in a flat file in the user's home directory. |
| 222 | + |
| 223 | +`Settings.json` |
| 224 | + |
| 225 | +```json |
| 226 | +"azure.noSystemKeychain": true |
| 227 | +``` |
| 228 | + |
| 229 | +:::image type="content" source="media/azure-connectivity/keychain.png" alt-text="Screenshot of Azure authentication keychain configuration."::: |
| 230 | + |
| 231 | +## Clear Azure account token cache |
| 232 | + |
| 233 | +Azure Data Studio maintains a cache of access tokens to prevent the throttling of token requests to Azure Active Directory (Azure AD). It's possible that Azure Data Studio's token cache may be outdated, which requires cleaning up expired access tokens from the application cache. |
| 234 | + |
| 235 | +Execute this command from **Command Palette (Ctrl/CMD + Shift + P)** to clear access tokens for linked Azure accounts: |
| 236 | + |
| 237 | +`Azure Accounts: Clear Azure Account Token Cache (accounts.clearTokenCache)` |
| 238 | + |
| 239 | +## Clear all saved Azure accounts |
| 240 | + |
| 241 | +Execute this command from **Command Palette (Ctrl/CMD + Shift + P)** to remove all linked Azure accounts from Azure Data Studio: |
| 242 | + |
| 243 | +**Clear all saved accounts (clearSavedAccounts)** |
0 commit comments