Files
fabric-cicd/devtools/debug_api.py
T
shirasassoonandShira Sassoon 98f095161d Closes #903 Retire DefaultAzureCredential phase 1 (awareness) (#899)
This pull request updates the authentication documentation for
`fabric-cicd` to deprecate the use of `DefaultAzureCredential` and
provide clear migration guidance to explicit credential methods. It
introduces a deprecation warning, reorganizes and clarifies
authentication examples, and adds guidance for using explicit credential
flows including Azure CLI, Azure PowerShell, and Managed Identity. The
changes emphasize security best practices and provide updated code
samples for different environments.

**Deprecation and migration guidance:**

* Added a deprecation warning for the use of `DefaultAzureCredential`,
advising users to migrate to explicit credential methods and providing
migration guidance in the documentation.
(`.changes/unreleased/optimization-20260325-161506.yaml`)
* Updated the authentication documentation to highlight the deprecation
and removal of the default credential flow, and clarified that explicit
`token_credential` parameters should be used in all scenarios except
Fabric Notebook runtime. (`docs/example/authentication.md`)

**Expanded and improved credential examples:**

* Replaced the default credential examples with explicit code samples
for Azure CLI (`AzureCliCredential`), Azure PowerShell
(`AzurePowerShellCredential`), and Managed Identity
(`ManagedIdentityCredential`) authentication flows, including updated
guidance and environment-specific instructions for local, Azure DevOps,
and GitHub Actions scenarios. (`docs/example/authentication.md`)
[[1]](diffhunk://#diff-209795f61181441c3bebe319157e9b2dec863d464945eb609858eec490c73a9eR35-R44)
[[2]](diffhunk://#diff-209795f61181441c3bebe319157e9b2dec863d464945eb609858eec490c73a9eL46-R66)
[[3]](diffhunk://#diff-209795f61181441c3bebe319157e9b2dec863d464945eb609858eec490c73a9eR86-R95)
[[4]](diffhunk://#diff-209795f61181441c3bebe319157e9b2dec863d464945eb609858eec490c73a9eL91-R136)
[[5]](diffhunk://#diff-209795f61181441c3bebe319157e9b2dec863d464945eb609858eec490c73a9eL141-R157)
[[6]](diffhunk://#diff-209795f61181441c3bebe319157e9b2dec863d464945eb609858eec490c73a9eL164-R170)
[[7]](diffhunk://#diff-209795f61181441c3bebe319157e9b2dec863d464945eb609858eec490c73a9eL187-R200)
[[8]](diffhunk://#diff-209795f61181441c3bebe319157e9b2dec863d464945eb609858eec490c73a9eL215-R221)
[[9]](diffhunk://#diff-209795f61181441c3bebe319157e9b2dec863d464945eb609858eec490c73a9eL237-R261)
[[10]](diffhunk://#diff-209795f61181441c3bebe319157e9b2dec863d464945eb609858eec490c73a9eR280-R296)
[[11]](diffhunk://#diff-209795f61181441c3bebe319157e9b2dec863d464945eb609858eec490c73a9eL320-R317)
[[12]](diffhunk://#diff-209795f61181441c3bebe319157e9b2dec863d464945eb609858eec490c73a9eL343-R358)

**Security and best practices:**

* Added notes advising against hardcoding credentials and recommended
using environment variables or secret management services, with specific
guidance for SPN + Secret authentication via CLI or PowerShell.
(`docs/example/authentication.md`)

These changes ensure users follow security best practices and have
clear, up-to-date examples for authenticating with `fabric-cicd` in a
variety of environments.

---------

Co-authored-by: Shira Sassoon <shirasassoon@microsoft.com>
2026-03-29 12:23:18 +03:00

44 lines
1.5 KiB
Python

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# The following is intended for developers of fabric-cicd to debug and call Fabric REST APIs locally from the github repo
from azure.identity import AzureCliCredential, AzurePowerShellCredential, ClientSecretCredential
from fabric_cicd import change_log_level, constants
from fabric_cicd._common._fabric_endpoint import FabricEndpoint
from fabric_cicd._common._validate_input import validate_token_credential
# Uncomment to enable debug
# change_log_level()
if __name__ == "__main__":
# Azure CLI auth - comment out to use a different auth method
token_credential = AzureCliCredential()
# Uncomment to use PowerShell auth
# token_credential = AzurePowerShellCredential()
# Uncomment to use SPN auth
# client_id = "your-client-id"
# client_secret = "your-client-secret"
# tenant_id = "your-tenant-id"
# token_credential = ClientSecretCredential(client_id=client_id, client_secret=client_secret, tenant_id=tenant_id)
# Create endpoint object
fe = FabricEndpoint(token_credential=validate_token_credential(token_credential))
# Set workspace id variable if needed in API url
workspace_id = "8f5c0cec-a8ea-48cd-9da4-871dc2642f4c"
# API endpoint url (placeholder)
api_url = f"{constants.DEFAULT_API_ROOT_URL}/v1/workspaces/{workspace_id}..."
print("Making API call...")
response = fe.invoke(
method="POST",
url=api_url,
body={},
)
print("Call completed.")