Skip to content

add python best practice and update python skills accordingly#295

Open
xiangyan99 wants to merge 11 commits intomicrosoft:mainfrom
xiangyan99:add_python_best_practice
Open

add python best practice and update python skills accordingly#295
xiangyan99 wants to merge 11 commits intomicrosoft:mainfrom
xiangyan99:add_python_best_practice

Conversation

@xiangyan99
Copy link
Copy Markdown
Member

add python best practice and update python skills accordingly

Comment thread .github/plugins/azure-sdk-python/skills/azure-containerregistry-py/SKILL.md Outdated
Comment thread .github/plugins/azure-sdk-python/skills/azure-identity-py/SKILL.md Outdated
8. **Use async clients** for high-throughput scenarios
1. **Pick sync OR async and stay consistent.** Do not mix `azure.xxx` sync clients with `azure.xxx.aio` async clients in the same call path. Choose one mode per module.
2. **Always use context managers for clients and async credentials.** Wrap every client in `with Client(...) as client:` (sync) or `async with Client(...) as client:` (async). For async `DefaultAzureCredential` from `azure.identity.aio`, also use `async with credential:` so tokens and transports are cleaned up.
3. **Use DefaultAzureCredential** for authentication
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be more specific about when it's appropriate to use DAC. See previous suggestion.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

7. **Configure proper CORS** for Web Chat channel
1. **Pick sync OR async and stay consistent.** Do not mix `azure.xxx` sync clients with `azure.xxx.aio` async clients in the same call path. Choose one mode per module.
2. **Always use context managers for clients and async credentials.** Wrap every client in `with Client(...) as client:` (sync) or `async with Client(...) as client:` (async). For async `DefaultAzureCredential` from `azure.identity.aio`, also use `async with credential:` so tokens and transports are cleaned up.
3. **Use DefaultAzureCredential** for authentication
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be more specific

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

8. **Monitor capacity usage** via Azure Monitor metrics
1. **Pick sync OR async and stay consistent.** Do not mix `azure.xxx` sync clients with `azure.xxx.aio` async clients in the same call path. Choose one mode per module.
2. **Always use context managers for clients and async credentials.** Wrap every client in `with Client(...) as client:` (sync) or `async with Client(...) as client:` (async). For async `DefaultAzureCredential` from `azure.identity.aio`, also use `async with credential:` so tokens and transports are cleaned up.
3. **Use DefaultAzureCredential** for authentication
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be more specific

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

8. **Use context manager** — Ensures proper client cleanup
1. **Pick sync OR async and stay consistent.** Do not mix `azure.xxx` sync clients with `azure.xxx.aio` async clients in the same call path. Choose one mode per module.
2. **Always use context managers for clients and async credentials.** Wrap every client in `with Client(...) as client:` (sync) or `async with Client(...) as client:` (async) to ensure proper cleanup. For async `DefaultAzureCredential` from `azure.identity.aio`, also use `async with credential:` so tokens and transports are cleaned up.
3. **Use DefaultAzureCredential** for authentication
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be more specific

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment thread .github/plugins/azure-sdk-python/skills/azure-monitor-opentelemetry-py/SKILL.md Outdated
7. **Set appropriate content types** for web-served blobs
1. **Pick sync OR async and stay consistent.** Do not mix `azure.storage.blob` sync clients with `azure.storage.blob.aio` async clients in the same call path. Choose one mode per module.
2. **Always use context managers for clients and async credentials.** Wrap every client in `with BlobServiceClient(...) as client:` (sync) or `async with BlobServiceClient(...) as client:` (async). For async `DefaultAzureCredential` from `azure.identity.aio`, also use `async with credential:` so tokens and transports are cleaned up.
3. **Use DefaultAzureCredential** instead of connection strings
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be more specific

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment thread .github/plugins/azure-sdk-python/skills/azure-storage-file-share-py/SKILL.md Outdated
xiangyan99 and others added 3 commits April 24, 2026 14:27
…y-py/SKILL.md

Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com>
…L.md

Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com>
…metry-exporter-py/SKILL.md

Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com>
Comment thread .github/skills/skill-creator/references/azure-sdk-patterns.md
xiangyan99 and others added 6 commits April 24, 2026 14:28
…metry-py/SKILL.md

Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com>
…re-py/SKILL.md

Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com>
Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com>
@kvenkatrajan
Copy link
Copy Markdown
Collaborator

@xiangyan99 - for @scottaddie's changes were these reflected back into the skill creator?

@kvenkatrajan kvenkatrajan self-requested a review April 24, 2026 23:26
@xiangyan99
Copy link
Copy Markdown
Member Author

@xiangyan99 - for @scottaddie's changes were these reflected back into the skill creator?

Yes. I updated in the skill-creator to use

  1. Use DefaultAzureCredential for code that runs locally. Use a specific token credential (e.g. ManagedIdentityCredential, WorkloadIdentityCredential) for code that runs in Azure.

# Conflicts:
#	.github/plugins/azure-sdk-python/skills/hosted-agents-v2-py/SKILL.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants