Skip to content

Commit

Permalink
Merge pull request #9 from jugi92/patch-1
Browse files Browse the repository at this point in the history
Adding username and password authentication example via az cli
  • Loading branch information
DaSenf1860 authored Aug 20, 2024
2 parents a36eea3 + c279f0c commit 664ea3a
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion usage_patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Here are some examples to make use of the SDK for specific tasks:
- [Do a "landing zone"- deployment](#do-a-landing-zone--deployment)
- [Bulk set labels for all items in a workspace](#bulk-set-labels-for-all-items-in-a-workspace)
- [Bulk suspend capacities](#bulk-suspend-capacities)
- [Use username and password authentication via az-cli](#use-username-and-password-authentication)



Expand Down Expand Up @@ -185,4 +186,36 @@ for cap in caps:
fac.suspend_capacity(subscription_id, resource_group_name, cap["name"])
except Exception as e:
print(e)
```
```

## Use username and password authentication
.env File
```
[email protected]
FABRIC_PASSWORD=...
```

Additional requirement: azure-cli
```
pip install azure-cli
```

Use Azure CLI login in Python:
```python
import os
from msfabricpysdkcore import FabricClientCore

def prepare_authentication():
# get username and password from environment variables
username = os.environ.get('FABRIC_USERNAME')
password = os.environ.get('FABRIC_PASSWORD')

cmd = f"az login --allow-no-subscriptions --username {username} --password {password}"
# execute python in command line
os.system(cmd)


prepare_authentication()

fc = FabricClientCore()
```

0 comments on commit 664ea3a

Please sign in to comment.