Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

### Other Changes

- Added AAD auth samples to distro
([#37352](https://github.com/Azure/azure-sdk-for-python/pull/37352))

## 1.6.2 (2024-09-05)

### Bugs Fixed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
An example to show an application using Opentelemetry tracing api and sdk with a Azure Managed Identity
Credential. Credentials are used for Azure Active Directory/EntraId Authentication.
"""
# You will need to install azure-identity
from azure.identity import ManagedIdentityCredential
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry import trace


credential = ManagedIdentityCredential(client_id="<client_id>")
configure_azure_monitor(
credential=credential,
)

tracer = trace.get_tracer(__name__)

with tracer.start_as_current_span("hello with aad managed identity"):
print("Hello, World!")

input()
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
An example to show an application using Opentelemetry tracing api and sdk with a Azure Client Secret
Credential. Credentials are used for Azure Active Directory/EntraId Authentication.
"""
# You will need to install azure-identity
from azure.identity import ClientSecretCredential
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry import trace

credential = ClientSecretCredential(
tenant_id="<tenant_id",
client_id="<client_id>",
client_secret="<client_secret>",
)
configure_azure_monitor(
credential=credential,
)

tracer = trace.get_tracer(__name__)

with tracer.start_as_current_span("hello with aad client secret"):
print("Hello, World!")

input()