Skip to content

Commit e14c82e

Browse files
author
naman-msft
committed
testing docs
1 parent bc4bcfd commit e14c82e

File tree

69 files changed

+10105
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+10105
-24
lines changed

proc.py

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
#!/usr/bin/env python3
2+
import os
3+
import re
4+
import shutil
5+
from pathlib import Path
6+
import yaml
7+
from openai import AzureOpenAI
8+
import argparse
9+
10+
# Azure OpenAI configuration
11+
AZURE_OPENAI_ENDPOINT = os.getenv("AZURE_OPENAI_ENDPOINT", "")
12+
AZURE_OPENAI_KEY = os.getenv("AZURE_OPENAI_API_KEY", "")
13+
AZURE_OPENAI_DEPLOYMENT = "gpt-4.1"
14+
AZURE_OPENAI_API_VERSION = "2024-12-01-preview"
15+
16+
def setup_azure_openai():
17+
"""Initialize Azure OpenAI client"""
18+
if not AZURE_OPENAI_ENDPOINT or not AZURE_OPENAI_KEY:
19+
raise ValueError("Please set AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_KEY environment variables")
20+
21+
client = AzureOpenAI(
22+
azure_endpoint=AZURE_OPENAI_ENDPOINT,
23+
api_key=AZURE_OPENAI_KEY,
24+
api_version=AZURE_OPENAI_API_VERSION
25+
)
26+
return client
27+
28+
def extract_title_from_markdown(file_path):
29+
"""Extract title from markdown file metadata or content"""
30+
with open(file_path, 'r', encoding='utf-8') as f:
31+
content = f.read()
32+
33+
# Try to extract YAML frontmatter
34+
yaml_match = re.match(r'^---\s*\n(.*?)\n---', content, re.DOTALL)
35+
if yaml_match:
36+
try:
37+
metadata = yaml.safe_load(yaml_match.group(1))
38+
if metadata and 'title' in metadata:
39+
return metadata['title']
40+
except:
41+
pass
42+
43+
# Try to find the first H1 heading
44+
h1_match = re.search(r'^#\s+(.+)$', content, re.MULTILINE)
45+
if h1_match:
46+
return h1_match.group(1).strip()
47+
48+
# Fallback to filename
49+
return Path(file_path).stem
50+
51+
def generate_folder_name(client, title, file_content_snippet):
52+
"""Use Azure OpenAI to generate an intuitive folder name"""
53+
prompt = f"""Given this document title: "{title}"
54+
And this content snippet from the document:
55+
{file_content_snippet[:500]}
56+
57+
Generate a concise folder name following these rules:
58+
1. Use PascalCase (capitalize first letter of each word)
59+
2. Be descriptive but concise (2-4 words max)
60+
3. Should reflect the main topic/technology
61+
4. Examples: GPUNodePoolAKS, DeployIGOnAKS, AzureMLWorkspace
62+
63+
Return ONLY the folder name, nothing else."""
64+
65+
try:
66+
response = client.chat.completions.create(
67+
model=AZURE_OPENAI_DEPLOYMENT,
68+
messages=[
69+
{"role": "system", "content": "You are a helpful assistant that generates folder names."},
70+
{"role": "user", "content": prompt}
71+
],
72+
temperature=0.3,
73+
max_tokens=50
74+
)
75+
folder_name = response.choices[0].message.content.strip()
76+
# Ensure it's valid folder name
77+
folder_name = re.sub(r'[^\w]', '', folder_name)
78+
return folder_name
79+
except Exception as e:
80+
print(f"Error generating folder name with Azure OpenAI: {e}")
81+
# Fallback to title-based name
82+
return ''.join(word.capitalize() for word in re.findall(r'\w+', title))[:30]
83+
84+
def pascal_to_kebab(name):
85+
"""Convert PascalCase to kebab-case, preserving acronyms like AKS."""
86+
# split on transitions from uppercase to lowercase or between acronyms
87+
tokens = re.findall(r'[A-Z](?:[a-z]+|[A-Z]*(?=[A-Z]|$))', name)
88+
return '-'.join(t.lower() for t in tokens)
89+
90+
def process_success_files(source_dir, target_dir, dry_run=False):
91+
"""Process all markdown files with 'success' in filename"""
92+
source_path = Path(source_dir)
93+
target_path = Path(target_dir)
94+
95+
if not source_path.exists():
96+
print(f"Source directory {source_dir} does not exist")
97+
return
98+
99+
# Setup Azure OpenAI
100+
try:
101+
client = setup_azure_openai()
102+
print("Azure OpenAI client initialized successfully")
103+
except Exception as e:
104+
print(f"Warning: Could not initialize Azure OpenAI: {e}")
105+
print("Will use fallback naming method")
106+
client = None
107+
108+
# Find all markdown files with 'success' in filename
109+
success_files = []
110+
for folder in source_path.iterdir():
111+
if folder.is_dir():
112+
for file in folder.glob("*.md"):
113+
if "success" in file.name.lower():
114+
success_files.append(file)
115+
116+
print(f"Found {len(success_files)} success files to process")
117+
118+
for file_path in success_files:
119+
try:
120+
print(f"\nProcessing: {file_path}")
121+
122+
# Extract title
123+
title = extract_title_from_markdown(file_path)
124+
print(f" Title: {title}")
125+
126+
# Read file content for OpenAI
127+
with open(file_path, 'r', encoding='utf-8') as f:
128+
content_snippet = f.read()[:1000]
129+
130+
# Generate folder name
131+
if client:
132+
folder_name = generate_folder_name(client, title, content_snippet)
133+
else:
134+
# Fallback method
135+
folder_name = ''.join(word.capitalize() for word in re.findall(r'\w+', title))[:30]
136+
137+
print(f" Folder name: {folder_name}")
138+
139+
# Convert to kebab-case for filename
140+
file_name = pascal_to_kebab(folder_name) + ".md"
141+
print(f" File name: {file_name}")
142+
143+
# Create target path
144+
target_folder = target_path / folder_name
145+
target_file = target_folder / file_name
146+
147+
if dry_run:
148+
print(f" [DRY RUN] Would create: {target_folder}")
149+
print(f" [DRY RUN] Would copy to: {target_file}")
150+
else:
151+
# Create folder and copy file
152+
target_folder.mkdir(parents=True, exist_ok=True)
153+
shutil.copy2(file_path, target_file)
154+
print(f" Created: {target_folder}")
155+
print(f" Copied to: {target_file}")
156+
157+
except Exception as e:
158+
print(f" ERROR processing {file_path}: {e}")
159+
160+
def main():
161+
parser = argparse.ArgumentParser(description="Process success markdown files")
162+
parser.add_argument("--dry-run", action="store_true", help="Show what would be done without actually doing it")
163+
args = parser.parse_args()
164+
165+
source_dir = "tools/success"
166+
target_dir = "scenarios"
167+
168+
print(f"Source directory: {source_dir}")
169+
print(f"Target directory: {target_dir}")
170+
171+
if args.dry_run:
172+
print("\n*** DRY RUN MODE - No files will be moved ***\n")
173+
174+
process_success_files(source_dir, target_dir, dry_run=args.dry_run)
175+
print("\nProcessing complete!")
176+
177+
if __name__ == "__main__":
178+
main()
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
title: Troubleshoot cluster connection issues with the API server
3+
description: Troubleshoot issues that occur when you attempt to connect to the API server of an Azure Kubernetes Service (AKS) cluster.
4+
ms.date: 08/30/2024
5+
ms.reviewer: rissing chiragpa, beleite, v-leedennis, v-weizhu
6+
ms.service: azure-kubernetes-service
7+
#Customer intent: As an Azure Kubernetes user, I want to take basic troubleshooting measures so that I can avoid cluster connectivity issues with the API server.
8+
ms.custom: sap:Connectivity,innovation-engine
9+
---
10+
11+
# Basic troubleshooting of cluster connection issues with the API server
12+
13+
This article discusses connection issues to an Azure Kubernetes Service (AKS) cluster when you can't reach the cluster's API server through the Kubernetes cluster command-line tool ([kubectl](https://kubernetes.io/docs/reference/kubectl/overview/)) or any other tool, such as using REST API through a programming language.
14+
15+
## Prerequisites
16+
17+
- [Azure CLI](/cli/azure/install-azure-cli).
18+
19+
## Root cause and solutions
20+
21+
Connection issues to the API server can occur for many reasons, but the root cause is often related to an error with one of these items:
22+
23+
- Network
24+
- Authentication
25+
- Authorization
26+
27+
You can take these common troubleshooting steps to check the connectivity to the AKS cluster's API server:
28+
29+
1. Enter the following [az aks show](/cli/azure/aks#az-aks-show) command in Azure CLI. This command gets the fully qualified domain name (FQDN) of your AKS cluster.
30+
31+
First, export your resource names to environment variables and add a random suffix to the resource group and cluster names for unique testing.
32+
33+
```azurecli
34+
export RANDOM_SUFFIX=$(head -c 3 /dev/urandom | xxd -p)
35+
export RESOURCE_GROUP="my-aks-rg$RANDOM_SUFFIX"
36+
export AKS_CLUSTER="myakscluster$RANDOM_SUFFIX"
37+
az aks show --resource-group $RESOURCE_GROUP --name $AKS_CLUSTER --query fqdn
38+
```
39+
40+
Results:
41+
42+
<!-- expected_similarity=0.3 -->
43+
44+
```output
45+
"xxxxxx-xxxxxxxx.hcp.eastus2.azmk8s.io"
46+
```
47+
48+
2. With the FQDN, check whether the API server is reachable from the client machine by using the name server lookup ([nslookup](/windows-server/administration/windows-commands/nslookup)), client URL ([curl](https://curl.se/docs/manpage.html)), and [telnet](/windows-server/administration/windows-commands/telnet) commands:
49+
50+
Replace `<cluster-fqdn>` with the actual FQDN returned from the previous step. For demonstration, we use a variable.
51+
52+
```bash
53+
export CLUSTER_FQDN=$(az aks show --resource-group $RESOURCE_GROUP --name $AKS_CLUSTER --query fqdn -o tsv)
54+
55+
# Check if the DNS Resolution is working:
56+
nslookup $CLUSTER_FQDN
57+
58+
# Then check if the API Server is reachable:
59+
curl -k -Iv https://$CLUSTER_FQDN
60+
61+
# Test raw TCP connectivity (output will vary depending on environment)
62+
timeout 5 telnet $CLUSTER_FQDN 443 || echo "Connection test completed"
63+
```
64+
65+
3. If the AKS cluster is private, make sure you run the command from a virtual machine (VM) that can access the AKS cluster's Azure Virtual Network. See [Options for connecting to the private cluster](/azure/aks/private-clusters#options-for-connecting-to-the-private-cluster).
66+
67+
4. If necessary, follow the steps in the troubleshooting article [Client IP address can't access the API server](client-ip-address-cannot-access-api-server.md), so the API server adds your client IP address to the IP ranges it authorizes.
68+
69+
5. Make sure the version of kubectl on your client machine isn't two or more minor versions behind the AKS cluster's version of that tool. To install the latest version of kubectl, run the [az aks install-cli](/cli/azure/aks#az-aks-install-cli) command in Azure CLI. You can then run [kubectl version](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#version) command to check the version number of the new installation.
70+
71+
For example, on Linux you would run these commands:
72+
73+
```shell
74+
sudo az aks install-cli
75+
kubectl version --client
76+
```
77+
78+
For other client operating systems, use these [kubectl installation instructions](https://kubernetes.io/docs/tasks/tools/).
79+
80+
6. If necessary, follow the steps in the troubleshooting article [Config file isn't available when connecting](config-file-is-not-available-when-connecting.md), so your Kubernetes configuration file (*config*) is valid and can be found at connection time.
81+
82+
7. If necessary, follow the steps in the troubleshooting article [User can't get cluster resources](user-cannot-get-cluster-resources.md), so you can list the details of your cluster nodes.
83+
84+
8. If you're using a firewall to control egress traffic from AKS worker nodes, make sure the firewall allows the [minimum required egress rules for AKS](/azure/aks/limit-egress-traffic).
85+
86+
9. Make sure the [network security group that's associated with AKS nodes](/azure/aks/concepts-security#azure-network-security-groups) allows communication on TCP port 10250 within the AKS nodes.
87+
88+
For other common troubleshooting steps, see [TCP time-outs when kubectl or other third-party tools connect to the API server](tcp-timeouts-kubetctl-third-party-tools-connect-api-server.md).
89+
90+
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: AADSTS7000222 - BadRequest or InvalidClientSecret error
3+
description: Learn how to troubleshoot the BadRequest or InvalidClientSecret error when you try to create or upgrade an Azure Kubernetes Service (AKS) cluster.
4+
ms.topic: article
5+
ms.date: 06/13/2024
6+
author: axelgMS
7+
ms.author: axelg
8+
ms.custom: sap:Create, Upgrade, Scale and Delete operations (cluster or nodepool), innovation-engine
9+
---
10+
11+
# AADSTS7000222 - BadRequest or InvalidClientSecret error
12+
13+
This article discusses how to identify and resolve the `AADSTS7000222` error (`BadRequest` or `InvalidClientSecret`) that occurs when you try to create or upgrade a Microsoft Azure Kubernetes Service (AKS) cluster.
14+
15+
## Prerequisites
16+
17+
- [Azure CLI](/cli/azure/install-azure-cli)
18+
19+
## Symptoms
20+
21+
When you try to create or upgrade an AKS cluster, you receive one of the following error messages.
22+
23+
| Error code | Message |
24+
|--|--|
25+
| `BadRequest` | **The credentials in ServicePrincipalProfile were invalid.** Please see <https://aka.ms/aks-sp-help> for more details. (Details: adal: Refresh request failed. Status Code = '401'. Response body: {"error": "invalid_client", "error_description": "**AADSTS7000222: The provided client secret keys for app '\<application-id>' are expired.** Visit the Azure portal to create new keys for your app: <https://aka.ms/NewClientSecret>, or consider using certificate credentials for added security: <https://aka.ms/certCreds>." |
26+
| `InvalidClientSecret` | **Customer auth is not valid for tenant: \<tenant-id>**: adal: Refresh request failed. Status Code = '401'. Response body: {"error": "invalid_client", "error_description": "**AADSTS7000222: The provided client secret keys for app '\<application-id>' are expired.** Visit the Azure portal to create new keys for your app: <https://aka.ms/NewClientSecret>, or consider using certificate credentials for added security: <https://aka.ms/certCreds>." |
27+
28+
## Cause
29+
30+
The issue that generates this service principal alert usually occurs for one of the following reasons:
31+
32+
- The client secret expired.
33+
34+
- Incorrect credentials were provided.
35+
36+
- The service principal doesn't exist within the Microsoft Entra ID tenant of the subscription.
37+
38+
#### Verify the cause
39+
40+
Use the following commands to retrieve the service principal profile for your AKS cluster and check the expiration date of the service principal. Make sure to set the appropriate variables for your AKS resource group and cluster name.
41+
42+
```azurecli
43+
SP_ID=$(az aks show --resource-group RESOURCE_GROUP_NAME \
44+
--name AKS_CLUSTER_NAME \
45+
--query servicePrincipalProfile.clientId \
46+
--output tsv)
47+
az ad app credential list --id "$SP_ID"
48+
```
49+
50+
Alternatively, you can verify that the service principal name and secret are correct and aren't expired. To do this, follow these steps:
51+
52+
1. In the [Azure portal](https://portal.azure.com), search for and select **Microsoft Entra ID**.
53+
54+
1. In the navigation pane of Microsoft Entra ID, select **App registrations**.
55+
56+
1. On the **Owned applications** tab, select the affected application.
57+
58+
1. Find the service principal name and secret information, and verify that the information is correct and current.
59+
60+
## Solution
61+
62+
1. In the [Update or rotate the credentials for an AKS cluster](/azure/aks/update-credentials) article, follow the instructions in one of the following article sections, as appropriate:
63+
64+
- [Reset the existing service principal credentials](/azure/aks/update-credentials#reset-the-existing-service-principal-credentials)
65+
- [Create a new service principal](/azure/aks/update-credentials#create-a-new-service-principal)
66+
67+
1. Using your new service principal credentials, follow the instructions in the [Update AKS cluster with service principal credentials](/azure/aks/update-credentials#update-aks-cluster-with-service-principal-credentials) section of that article.
68+
69+
## More information
70+
71+
- [Use a service principal with Azure Kubernetes Service (AKS)](/azure/aks/kubernetes-service-principal) (especially the [Troubleshoot](/azure/aks/kubernetes-service-principal#troubleshoot) section)
72+
73+
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]

0 commit comments

Comments
 (0)