Skip to content

Commit 3af4ee9

Browse files
authored
Migrate prefect-azure docs to Integrations section of the Prefect docs (#12794)
1 parent 223bab2 commit 3af4ee9

File tree

13 files changed

+167
-4
lines changed

13 files changed

+167
-4
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
collectionName: prefect-azure
22
author: Prefect
33
authorUrl: https://prefect.io
4-
documentation: https://prefecthq.github.io/prefect-azure/
4+
documentation: prefect-azure
55
iconUrl: /img/collections/azure.png
6-
tag: Azure
6+
tag: Azure
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: prefect_azure.blob_storage
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: prefect_azure.container_instance
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: prefect_azure.workers.container_instance
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: prefect_azure.cosmos_db
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: prefect_azure.credentials
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: prefect_azure.deployments.steps
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# prefect-azure
2+
3+
<p align="center">
4+
<a href="https://pypi.python.org/pypi/prefect-azure/" alt="PyPI version">
5+
<img alt="PyPI" src="https://img.shields.io/pypi/v/prefect-azure?color=26272B&labelColor=090422"></a>
6+
<a href="https://pepy.tech/badge/prefect-azure/" alt="Downloads">
7+
<img src="https://img.shields.io/pypi/dm/prefect-azure?color=26272B&labelColor=090422" /></a>
8+
</p>
9+
10+
`prefect-azure` is a collection of Prefect integrations for orchestration workflows with Azure.
11+
12+
## Getting Started
13+
14+
### Installation
15+
16+
Install `prefect-azure` with `pip`
17+
18+
```bash
19+
pip install prefect-azure
20+
```
21+
22+
To use Blob Storage:
23+
```bash
24+
pip install "prefect-azure[blob_storage]"
25+
```
26+
27+
To use Cosmos DB:
28+
```bash
29+
pip install "prefect-azure[cosmos_db]"
30+
```
31+
32+
To use ML Datastore:
33+
```bash
34+
pip install "prefect-azure[ml_datastore]"
35+
```
36+
37+
## Examples
38+
39+
### Download a blob
40+
41+
```python
42+
from prefect import flow
43+
44+
from prefect_azure import AzureBlobStorageCredentials
45+
from prefect_azure.blob_storage import blob_storage_download
46+
47+
@flow
48+
def example_blob_storage_download_flow():
49+
connection_string = "connection_string"
50+
blob_storage_credentials = AzureBlobStorageCredentials(
51+
connection_string=connection_string,
52+
)
53+
data = blob_storage_download(
54+
blob="prefect.txt",
55+
container="prefect",
56+
azure_credentials=blob_storage_credentials,
57+
)
58+
return data
59+
60+
example_blob_storage_download_flow()
61+
```
62+
63+
Use `with_options` to customize options on any existing task or flow:
64+
```python
65+
custom_blob_storage_download_flow = example_blob_storage_download_flow.with_options(
66+
name="My custom task name",
67+
retries=2,
68+
retry_delay_seconds=10,
69+
)
70+
```
71+
72+
### Run a command on an Azure container instance
73+
74+
```python
75+
from prefect import flow
76+
from prefect_azure import AzureContainerInstanceCredentials
77+
from prefect_azure.container_instance import AzureContainerInstanceJob
78+
79+
80+
@flow
81+
def container_instance_job_flow():
82+
aci_credentials = AzureContainerInstanceCredentials.load("MY_BLOCK_NAME")
83+
container_instance_job = AzureContainerInstanceJob(
84+
aci_credentials=aci_credentials,
85+
resource_group_name="azure_resource_group.example.name",
86+
subscription_id="<MY_AZURE_SUBSCRIPTION_ID>",
87+
command=["echo", "hello world"],
88+
)
89+
return container_instance_job.run()
90+
```
91+
92+
### Use Azure Container Instance as infrastructure
93+
94+
If we have `a_flow_module.py`:
95+
96+
```python
97+
from prefect import flow, get_run_logger
98+
99+
@flow
100+
def log_hello_flow(name="Marvin"):
101+
logger = get_run_logger()
102+
logger.info(f"{name} said hello!")
103+
104+
if __name__ == "__main__":
105+
log_hello_flow()
106+
```
107+
108+
We can run that flow using an Azure Container Instance, but first create the infrastructure block:
109+
110+
```python
111+
from prefect_azure import AzureContainerInstanceCredentials
112+
from prefect_azure.container_instance import AzureContainerInstanceJob
113+
114+
container_instance_job = AzureContainerInstanceJob(
115+
aci_credentials=AzureContainerInstanceCredentials.load("MY_BLOCK_NAME"),
116+
resource_group_name="azure_resource_group.example.name",
117+
subscription_id="<MY_AZURE_SUBSCRIPTION_ID>",
118+
)
119+
container_instance_job.save("aci-dev")
120+
```
121+
122+
Then, create the deployment either on the UI or through the CLI:
123+
```bash
124+
prefect deployment build a_flow_module.py:log_hello_flow --name aci-dev -ib container-instance-job/aci-dev
125+
```
126+
127+
Visit [Prefect Deployments](https://docs.prefect.io/tutorials/deployments/) for more information about deployments.
128+
129+
## Azure Container Instance Worker
130+
The Azure Container Instance worker is an excellent way to run
131+
your workflows on Azure.
132+
133+
To get started, create an Azure Container Instances typed work pool:
134+
```
135+
prefect work-pool create -t azure-container-instance my-aci-work-pool
136+
```
137+
138+
Then, run a worker that pulls jobs from the work pool:
139+
```
140+
prefect worker start -n my-aci-worker -p my-aci-work-pool
141+
```
142+
143+
The worker should automatically read the work pool's type and start an
144+
Azure Container Instance worker.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: prefect_azure.ml_datastore

mkdocs.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,17 @@ nav:
237237
- integrations/index.md
238238
- Using Integrations: integrations/usage.md
239239
- Contributing Integrations: integrations/contribute.md
240+
- Libraries:
241+
- Azure:
242+
- integrations/prefect-azure/index.md
243+
- Credentials: integrations/prefect-azure/credentials.md
244+
- Blob Storage: integrations/prefect-azure/blob_storage.md
245+
- Cosmos DB: integrations/prefect-azure/cosmos_db.md
246+
- ML Datastore: integrations/prefect-azure/ml_datastore.md
247+
- Container Instance Block: integrations/prefect-azure/container_instance.md
248+
- Container Instance Worker: integrations/prefect-azure/container_instance_worker.md
249+
- Deployments:
250+
- Steps: integrations/prefect-azure/deployments/steps.md
240251
- API Reference:
241252
- api-ref/index.md
242253
- Python SDK:

netlify.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
base = ""
1010
command = """
1111
pip install --upgrade pip \
12+
&& pip install src/integrations/* \
1213
&& pip install --upgrade --upgrade-strategy eager -e ".[dev]" \
1314
&& pip install git+https://oauth:${MKDOCS_MATERIAL_INSIDERS_REPO_RO}@github.com/PrefectHQ/mkdocs-material-insiders.git@1471e7595c14a067031600ec18e3cc8d7964e4aa\
1415
&& prefect dev build-docs \

src/integrations/prefect-azure/prefect_azure/container_instance.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""
2-
<span class="badge-api experimental"/>
32
Integrations with the Azure Container Instances service.
43
Note this module is experimental. The interfaces within may change without notice.
54
@@ -62,6 +61,7 @@
6261
)
6362
```
6463
"""
64+
6565
import datetime
6666
import json
6767
import random
@@ -179,7 +179,6 @@ class AzureContainerInstanceJobResult(InfrastructureResult):
179179

180180
class AzureContainerInstanceJob(Infrastructure):
181181
"""
182-
<span class="badge-api experimental"/>
183182
Run a command using a container on Azure Container Instances.
184183
Note this block is experimental. The interface may change without notice.
185184
"""

src/integrations/prefect-azure/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ version_file = "prefect_azure/_version.py"
7777
root = "../../.."
7878
tag_regex = "^prefect-azure-(?P<version>\\d+\\.\\d+\\.\\d+)$"
7979
fallback_version = "0.0.0"
80+
git_describe_command = 'git describe --dirty --tags --long --match "prefect-azure-*[0-9]*"'
8081

8182
[tool.flake8]
8283
exclude = [".git", "__pycache__", "build", "dist"]

0 commit comments

Comments
 (0)