or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

advanced-authentication-flows.mdauthorization-code-authentication.mdazure-developer-cli-authentication.mdazure-pipelines-authentication.mdclient-assertion-authentication.mdconfiguration-and-utilities.mdcredential-chaining.mddefault-azure-credential.mddeveloper-tool-credentials.mdenvironment-credential.mdindex.mdinteractive-user-authentication.mdmanaged-identity-credential.mdservice-principal-authentication.mdshared-token-cache-authentication.mdusername-password-authentication.mdvisual-studio-code-authentication.md

visual-studio-code-authentication.mddocs/

0

# Visual Studio Code Authentication

1

2

**DEPRECATED:** Authenticates using Visual Studio Code Azure Account extension credentials. This credential is deprecated due to the underlying VS Code Azure Account extension being deprecated.

3

4

## Capabilities

5

6

### Visual Studio Code Credential

7

8

Enables authentication using cached credentials from VS Code Azure Account extension.

9

10

```java { .api }

11

/**

12

* Visual Studio Code credential for development environments

13

* @deprecated VS Code Azure Account extension has been deprecated

14

*/

15

@Deprecated

16

class VisualStudioCodeCredential implements TokenCredential {

17

Mono<AccessToken> getToken(TokenRequestContext request);

18

// Note: Does not support synchronous getTokenSync method

19

}

20

21

@Deprecated

22

class VisualStudioCodeCredentialBuilder extends CredentialBuilderBase<VisualStudioCodeCredentialBuilder> {

23

VisualStudioCodeCredentialBuilder tenantId(String tenantId);

24

VisualStudioCodeCredentialBuilder additionallyAllowedTenants(String... additionallyAllowedTenants);

25

VisualStudioCodeCredentialBuilder additionallyAllowedTenants(List<String> additionallyAllowedTenants);

26

VisualStudioCodeCredential build();

27

}

28

```

29

30

## Deprecation Notice

31

32

⚠️ **This credential is deprecated** because:

33

- VS Code Azure Account extension has been deprecated by Microsoft

34

- Known compatibility issues with Azure Account extension versions newer than 0.9.11

35

- No longer maintained or recommended for new development

36

37

## Legacy Usage Examples

38

39

```java

40

import com.azure.identity.VisualStudioCodeCredential;

41

import com.azure.identity.VisualStudioCodeCredentialBuilder;

42

43

// DEPRECATED - Not recommended for new development

44

@SuppressWarnings("deprecation")

45

TokenCredential credential = new VisualStudioCodeCredentialBuilder()

46

.build();

47

48

// With specific tenant

49

@SuppressWarnings("deprecation")

50

TokenCredential tenantCredential = new VisualStudioCodeCredentialBuilder()

51

.tenantId("your-tenant-id")

52

.build();

53

54

// Multi-tenant support

55

@SuppressWarnings("deprecation")

56

TokenCredential multiTenantCredential = new VisualStudioCodeCredentialBuilder()

57

.tenantId("primary-tenant")

58

.additionallyAllowedTenants("tenant1", "tenant2")

59

.build();

60

```

61

62

## Migration Recommendations

63

64

**Recommended Alternatives for VS Code Development:**

65

66

### 1. Azure CLI Credential (Recommended)

67

```java

68

// Modern replacement for VS Code authentication

69

TokenCredential credential = new AzureCliCredentialBuilder()

70

.build();

71

72

// Setup: Install Azure CLI and run 'az login'

73

```

74

75

### 2. Default Azure Credential Chain

76

```java

77

// Comprehensive authentication chain including Azure CLI

78

TokenCredential credential = new DefaultAzureCredentialBuilder()

79

.build();

80

```

81

82

### 3. Interactive Browser Credential

83

```java

84

// For interactive development scenarios

85

TokenCredential credential = new InteractiveBrowserCredentialBuilder()

86

.clientId("your-client-id")

87

.build();

88

```

89

90

## Known Issues

91

92

- **Extension version compatibility**: Doesn't work with Azure Account extension versions newer than 0.9.11

93

- **Token cache access**: May fail to access VS Code token cache on some systems

94

- **Authentication failures**: Inconsistent behavior across different VS Code versions

95

- **Platform limitations**: Limited support on some operating systems

96

97

## Migration Steps

98

99

1. **Remove VisualStudioCodeCredential usage:**

100

```java

101

// Remove deprecated credential

102

// TokenCredential credential = new VisualStudioCodeCredentialBuilder().build();

103

```

104

105

2. **Install Azure CLI:**

106

```bash

107

# Install Azure CLI for your platform

108

# macOS: brew install azure-cli

109

# Windows: winget install Microsoft.AzureCLI

110

# Linux: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

111

```

112

113

3. **Authenticate with Azure CLI:**

114

```bash

115

az login

116

```

117

118

4. **Update to use AzureCliCredential:**

119

```java

120

TokenCredential credential = new AzureCliCredentialBuilder()

121

.build();

122

```

123

124

## VS Code Development Workflow (Legacy)

125

126

**For maintaining existing code only:**

127

128

1. **Install VS Code Azure Account extension** (version ≤ 0.9.11)

129

2. **Sign in to Azure** through the extension

130

3. **Use the deprecated credential** (not recommended for new projects)

131

132

## Exception Handling

133

134

Throws `CredentialUnavailableException` when:

135

- VS Code Azure Account extension is not installed

136

- Extension version is incompatible (> 0.9.11)

137

- User is not signed in through the extension

138

- Token cache is inaccessible or corrupted

139

140

## Development Environment Setup

141

142

**Recommended modern setup for VS Code development:**

143

144

```bash

145

# Install Azure CLI

146

az login

147

148

# Or use Azure PowerShell

149

Connect-AzAccount

150

```

151

152

Then use:

153

```java

154

// Use DefaultAzureCredential which includes Azure CLI

155

TokenCredential credential = new DefaultAzureCredentialBuilder()

156

.build();

157

```

158

159

This provides a more reliable and supported authentication experience for development scenarios.