Skip to content

Commit 837a60a

Browse files
committed
NSOL-6228: updating authentication process in anf documentation
1 parent f2ade55 commit 837a60a

2 files changed

Lines changed: 58 additions & 57 deletions

File tree

netapp_dataops_traditional/docs/anf_mcp_server_readme.md

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -47,45 +47,39 @@ After installation, the `netapp_dataops_anf_mcp.py` command will be available in
4747

4848
### Azure Authentication
4949

50-
The MCP server uses **Azure CLI authentication** (`AzureCliCredential`) and automatically retrieves your subscription ID from the active Azure CLI session.
50+
The MCP server uses **`DefaultAzureCredential`** from `azure-identity`, which automatically selects the appropriate credential based on the environment — no configuration required. The active subscription is resolved via the Azure SDK's `SubscriptionClient`.
5151

52-
#### Required Setup
53-
54-
1. **Install Azure CLI**: Follow the [installation guide](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
52+
> **No secrets or environment variables are required.** The credential resolves automatically based on the environment.
5553
56-
2. **Login to Azure**:
57-
```bash
58-
az login
59-
```
54+
#### Required Setup
6055

61-
3. **If you have access to multiple tenants, specify the tenant ID**:
62-
```bash
63-
az login --tenant <TENANT-ID>
64-
```
56+
Authenticate once via Azure CLI:
6557

66-
4. **If you have multiple subscriptions, set the active one**:
67-
```bash
68-
az account set --subscription <SUBSCRIPTION_ID>
69-
```
58+
```bash
59+
# Login to Azure (opens browser)
60+
az login
7061

71-
5. **Verify your active subscription**:
72-
```bash
73-
az account show
74-
```
62+
# If you have access to multiple tenants, specify the tenant ID
63+
az login --tenant <TENANT_ID>
7564

76-
#### How It Works
65+
# If you have multiple subscriptions, set the active one
66+
az account set --subscription <SUBSCRIPTION_ID>
7767

78-
- The MCP server automatically runs `az account show` to detect your active subscription
79-
- Subscription ID is retrieved dynamically on each operation
80-
- Respects your Azure CLI tenant and subscription context
81-
- No need to configure or store subscription ID in config files or environment variables
68+
# Verify active session (optional – subscription is auto-detected via the SDK)
69+
az account show
70+
```
8271

83-
#### Benefits
72+
**How It Works:**
73+
- `DefaultAzureCredential` is instantiated and passed to `SubscriptionClient`
74+
- The first available subscription is resolved via the Azure SDK
75+
- The resolved `subscription_id` is used to initialize `NetAppManagementClient`
76+
- The client is cached in a singleton (`ANFClientManager`) and reused across calls
8477

85-
- **Simplified Setup**: No subscription ID in config files or function parameters
86-
- **Better Security**: Subscription ID not stored anywhere
87-
- **Multi-Tenant Support**: Easy switching between tenants/subscriptions with Azure CLI
88-
- **Automatic Detection**: Works seamlessly with your Azure CLI context
78+
**Benefits:**
79+
- **Zero secrets** – No `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, or `AZURE_TENANT_ID` needed
80+
- **Portable** – Works in local dev, CI/CD, containers, and Azure-hosted environments
81+
- **Subscription auto-resolved** – No subscription ID in config files or function parameters
82+
- **Multi-tenant support** – Respects `az login --tenant` or workload identity federation
8983

9084
### ANF Configuration (Optional)
9185

@@ -130,7 +124,7 @@ The configuration file is stored at `~/.netapp_dataops/anf_config.json` and cont
130124
}
131125
```
132126

133-
> **📝 Note:** The subscription ID is **not** stored in the configuration file. It is automatically retrieved from your active Azure CLI session using `az account show`.
127+
> **📝 Note:** The subscription ID is **not** stored in the configuration file. It is automatically resolved at runtime via `DefaultAzureCredential` and the Azure SDK's `SubscriptionClient`.
134128
135129
#### Configuration Benefits and Usage
136130

@@ -281,7 +275,9 @@ Set up disaster recovery:
281275
1. **Authentication Failed**:
282276
```bash
283277
az login
284-
# or check service principal credentials
278+
# or for a specific tenant
279+
az login --tenant <TENANT_ID>
280+
# verify active session
285281
az account show
286282
```
287283

netapp_dataops_traditional/docs/anf_readme.md

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Built on the [Azure NetApp Files Python SDK](https://docs.microsoft.com/en-us/py
1818
- [Prerequisites](#prerequisites)
1919
- [Installation Instructions](#installation-instructions)
2020
- [Authentication](#authentication)
21-
- [Azure CLI Authentication (Required)](#azure-cli-authentication-required)
21+
- [Authentication Methods (DefaultAzureCredential)](#authentication-methods-defaultazurecredential)
2222
- [Configuration](#configuration)
2323
- [Option 1: Interactive Configuration (Recommended)](#option-1-interactive-configuration-recommended)
2424
- [Option 2: Manual Configuration](#option-2-manual-configuration)
@@ -104,44 +104,49 @@ python3 -m pip install 'netapp-dataops-traditional[azure]'
104104

105105
## Authentication
106106

107-
The ANF module uses **Azure CLI authentication** (`AzureCliCredential`) and automatically retrieves your subscription ID from the active Azure CLI session.
107+
The ANF module uses **`DefaultAzureCredential`** from `azure-identity`, which automatically chains through multiple authentication methods without requiring any environment variables or secrets. The active subscription is resolved via the Azure SDK's `SubscriptionClient`.
108108

109-
<a name="option-1-azure-cli-recommended"></a>
109+
<a name="authentication-methods-defaultazurecredential"></a>
110110

111-
### Azure CLI Authentication (Required)
111+
### Authentication Methods (DefaultAzureCredential)
112+
113+
`DefaultAzureCredential` automatically selects the appropriate credential based on the environment — no configuration required.
114+
115+
> **No secrets or environment variables are required.** The credential resolves automatically based on the environment.
116+
117+
#### Required Setup
118+
119+
Authenticate once via Azure CLI:
112120

113-
**Required Setup:**
114121
```bash
115122
# Install Azure CLI (if not already installed)
116123
# https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
117124

118-
# Login to Azure
125+
# Login to Azure (opens browser)
119126
az login
120127

121128
# If you have access to multiple tenants, specify the tenant ID
122-
az login --tenant <TENANT-ID>
129+
az login --tenant <TENANT_ID>
123130

124131
# If you have multiple subscriptions, set the active one
125132
az account set --subscription <SUBSCRIPTION_ID>
126133

127-
# Verify your active subscription
134+
# Verify active session (optional – subscription is auto-detected via the SDK)
128135
az account show
129136
```
130137

131138
**How It Works:**
132-
- The toolkit automatically runs `az account show` to detect your active subscription
133-
- Subscription ID is retrieved dynamically on each operation
134-
- Respects your Azure CLI tenant and subscription context
135-
- No need to configure or store subscription ID in config files or environment variables
139+
- `DefaultAzureCredential` is instantiated and passed to `SubscriptionClient`
140+
- The first available subscription is resolved via the Azure SDK
141+
- The resolved `subscription_id` is used to initialize `NetAppManagementClient`
142+
- The client is cached in a singleton (`ANFClientManager`) and reused across calls
136143

137144
**Benefits:**
138-
-**Simplified Setup**: No subscription ID in config files or function parameters
139-
-**Better Security**: Subscription ID not stored anywhere
140-
-**Multi-tenant Support**: Automatically respects `az login --tenant`
141-
-**Multi-subscription Support**: Honors `az account set --subscription`
142-
-**Consistent Authentication**: Uses same credentials as Azure CLI
143-
144-
**Note:** Service Principal and environment variable authentication methods are no longer supported. The module now exclusively uses Azure CLI authentication for consistency and security.
145+
- **Zero secrets** – No `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, or `AZURE_TENANT_ID` needed
146+
- **Portable** – Works in local dev, CI/CD, containers, and Azure-hosted environments
147+
- **Subscription auto-resolved** – No subscription ID in config files or function parameters
148+
- **Multi-tenant support** – Respects `az login --tenant` or workload identity federation
149+
- **Production-ready** – Managed Identity support means no credential rotation required
145150

146151
## Configuration
147152

@@ -184,10 +189,10 @@ python3 -c "from netapp_dataops.traditional.anf.config import create_anf_config;
184189
**Note:** Subscription ID is NOT needed - it's automatically detected from your Azure CLI session.
185190

186191
**Benefits:**
187-
- **Simplified function calls** - Pass only unique parameters
188-
- 🎯 **Consistent defaults** - Reuse infrastructure settings across operations
189-
- 🛡️ **Reduced errors** - Pre-validated configuration values
190-
- 📝 **Version control friendly** - Config file can be shared across teams
192+
- **Simplified function calls** - Pass only unique parameters
193+
- **Consistent defaults** - Reuse infrastructure settings across operations
194+
- **Reduced errors** - Pre-validated configuration values
195+
- **Version control friendly** - Config file can be shared across teams
191196

192197
### Configuration File Location
193198

@@ -209,7 +214,7 @@ The configuration is automatically saved to:
209214
}
210215
```
211216

212-
**Note:** Subscription ID is not stored in the config file. It's automatically retrieved from your Azure CLI session via `az account show`.
217+
**Note:** Subscription ID is not stored in the config file. It's automatically resolved at runtime via `DefaultAzureCredential` and the Azure SDK's `SubscriptionClient`.
213218

214219
### Usage with Configuration
215220

@@ -1338,7 +1343,7 @@ czr_result = anf.create_replication(
13381343
Report any issues via GitHub: https://github.com/NetApp/netapp-data-science-toolkit/issues.
13391344
13401345
**Common Issues:**
1341-
- **Authentication failures**: Ensure Azure CLI is logged in or service principal credentials are correct
1346+
- **Authentication failures**: Ensure `az login` has been run for local development, or a Managed Identity is assigned in production
13421347
- **Permission denied**: Verify NetApp Contributor role is assigned to your account/service principal
13431348
- **Resource not found**: Check that NetApp Account, Capacity Pool, and delegated subnet exist
13441349
- **Region limitations**: Verify Azure NetApp Files is available in your target region

0 commit comments

Comments
 (0)