prefect-azure


Nameprefect-azure JSON
Version 0.4.2 PyPI version JSON
download
home_pageNone
SummaryPrefect integrations with Microsoft Azure services
upload_time2024-11-20 17:07:44
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseApache License 2.0
keywords prefect
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # prefect-azure

<p align="center">
    <a href="https://pypi.python.org/pypi/prefect-azure/" alt="PyPI version">
        <img alt="PyPI" src="https://img.shields.io/pypi/v/prefect-azure?color=26272B&labelColor=090422"></a>
    <a href="https://pepy.tech/badge/prefect-azure/" alt="Downloads">
        <img src="https://img.shields.io/pypi/dm/prefect-azure?color=26272B&labelColor=090422" /></a>
</p>

`prefect-azure` is a collection of Prefect integrations for orchestration workflows with Azure.

## Getting Started

### Installation

Install `prefect-azure` with `pip`

```bash
pip install prefect-azure
```

To use Blob Storage:

```bash
pip install "prefect-azure[blob_storage]"
```

To use Cosmos DB:

```bash
pip install "prefect-azure[cosmos_db]"
```

To use ML Datastore:

```bash
pip install "prefect-azure[ml_datastore]"
```

## Examples

### Download a blob

```python
from prefect import flow

from prefect_azure import AzureBlobStorageCredentials
from prefect_azure.blob_storage import blob_storage_download

@flow
def example_blob_storage_download_flow():
    connection_string = "connection_string"
    blob_storage_credentials = AzureBlobStorageCredentials(
        connection_string=connection_string,
    )
    data = blob_storage_download(
        blob="prefect.txt",
        container="prefect",
        azure_credentials=blob_storage_credentials,
    )
    return data

example_blob_storage_download_flow()
```

Use `with_options` to customize options on any existing task or flow:

```python
custom_blob_storage_download_flow = example_blob_storage_download_flow.with_options(
    name="My custom task name",
    retries=2,
    retry_delay_seconds=10,
)
```

### Run a command on an Azure container instance

```python
from prefect import flow
from prefect_azure import AzureContainerInstanceCredentials
from prefect_azure.container_instance import AzureContainerInstanceJob


@flow
def container_instance_job_flow():
    aci_credentials = AzureContainerInstanceCredentials.load("MY_BLOCK_NAME")
    container_instance_job = AzureContainerInstanceJob(
        aci_credentials=aci_credentials,
        resource_group_name="azure_resource_group.example.name",
        subscription_id="<MY_AZURE_SUBSCRIPTION_ID>",
        command=["echo", "hello world"],
    )
    return container_instance_job.run()
```

### Use Azure Container Instance as infrastructure

If we have `a_flow_module.py`:

```python
from prefect import flow
from prefect.logging import get_run_logger

@flow
def log_hello_flow(name="Marvin"):
    logger = get_run_logger()
    logger.info(f"{name} said hello!")

if __name__ == "__main__":
    log_hello_flow()
```

We can run that flow using an Azure Container Instance, but first create the infrastructure block:

```python
from prefect_azure import AzureContainerInstanceCredentials
from prefect_azure.container_instance import AzureContainerInstanceJob

container_instance_job = AzureContainerInstanceJob(
    aci_credentials=AzureContainerInstanceCredentials.load("MY_BLOCK_NAME"),
    resource_group_name="azure_resource_group.example.name",
    subscription_id="<MY_AZURE_SUBSCRIPTION_ID>",
)
container_instance_job.save("aci-dev")
```

Then, create the deployment either on the UI or through the CLI:

```bash
prefect deployment build a_flow_module.py:log_hello_flow --name aci-dev -ib container-instance-job/aci-dev
```

Visit [Prefect Deployments](https://docs.prefect.io/latest/deploy/) for more information about deployments.

## Azure Container Instance Worker

The Azure Container Instance worker is an excellent way to run
your workflows on Azure.

To get started, create an Azure Container Instances typed work pool:

```
prefect work-pool create -t azure-container-instance my-aci-work-pool
```

Then, run a worker that pulls jobs from the work pool:

```
prefect worker start -n my-aci-worker -p my-aci-work-pool
```

The worker should automatically read the work pool's type and start an
Azure Container Instance worker.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "prefect-azure",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "prefect",
    "author": null,
    "author_email": "\"Prefect Technologies, Inc.\" <help@prefect.io>",
    "download_url": "https://files.pythonhosted.org/packages/3a/01/2acad3e636f0125a32719bc8f9f2f1435f04102b52112423c0b037c7bb63/prefect_azure-0.4.2.tar.gz",
    "platform": null,
    "description": "# prefect-azure\n\n<p align=\"center\">\n    <a href=\"https://pypi.python.org/pypi/prefect-azure/\" alt=\"PyPI version\">\n        <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/prefect-azure?color=26272B&labelColor=090422\"></a>\n    <a href=\"https://pepy.tech/badge/prefect-azure/\" alt=\"Downloads\">\n        <img src=\"https://img.shields.io/pypi/dm/prefect-azure?color=26272B&labelColor=090422\" /></a>\n</p>\n\n`prefect-azure` is a collection of Prefect integrations for orchestration workflows with Azure.\n\n## Getting Started\n\n### Installation\n\nInstall `prefect-azure` with `pip`\n\n```bash\npip install prefect-azure\n```\n\nTo use Blob Storage:\n\n```bash\npip install \"prefect-azure[blob_storage]\"\n```\n\nTo use Cosmos DB:\n\n```bash\npip install \"prefect-azure[cosmos_db]\"\n```\n\nTo use ML Datastore:\n\n```bash\npip install \"prefect-azure[ml_datastore]\"\n```\n\n## Examples\n\n### Download a blob\n\n```python\nfrom prefect import flow\n\nfrom prefect_azure import AzureBlobStorageCredentials\nfrom prefect_azure.blob_storage import blob_storage_download\n\n@flow\ndef example_blob_storage_download_flow():\n    connection_string = \"connection_string\"\n    blob_storage_credentials = AzureBlobStorageCredentials(\n        connection_string=connection_string,\n    )\n    data = blob_storage_download(\n        blob=\"prefect.txt\",\n        container=\"prefect\",\n        azure_credentials=blob_storage_credentials,\n    )\n    return data\n\nexample_blob_storage_download_flow()\n```\n\nUse `with_options` to customize options on any existing task or flow:\n\n```python\ncustom_blob_storage_download_flow = example_blob_storage_download_flow.with_options(\n    name=\"My custom task name\",\n    retries=2,\n    retry_delay_seconds=10,\n)\n```\n\n### Run a command on an Azure container instance\n\n```python\nfrom prefect import flow\nfrom prefect_azure import AzureContainerInstanceCredentials\nfrom prefect_azure.container_instance import AzureContainerInstanceJob\n\n\n@flow\ndef container_instance_job_flow():\n    aci_credentials = AzureContainerInstanceCredentials.load(\"MY_BLOCK_NAME\")\n    container_instance_job = AzureContainerInstanceJob(\n        aci_credentials=aci_credentials,\n        resource_group_name=\"azure_resource_group.example.name\",\n        subscription_id=\"<MY_AZURE_SUBSCRIPTION_ID>\",\n        command=[\"echo\", \"hello world\"],\n    )\n    return container_instance_job.run()\n```\n\n### Use Azure Container Instance as infrastructure\n\nIf we have `a_flow_module.py`:\n\n```python\nfrom prefect import flow\nfrom prefect.logging import get_run_logger\n\n@flow\ndef log_hello_flow(name=\"Marvin\"):\n    logger = get_run_logger()\n    logger.info(f\"{name} said hello!\")\n\nif __name__ == \"__main__\":\n    log_hello_flow()\n```\n\nWe can run that flow using an Azure Container Instance, but first create the infrastructure block:\n\n```python\nfrom prefect_azure import AzureContainerInstanceCredentials\nfrom prefect_azure.container_instance import AzureContainerInstanceJob\n\ncontainer_instance_job = AzureContainerInstanceJob(\n    aci_credentials=AzureContainerInstanceCredentials.load(\"MY_BLOCK_NAME\"),\n    resource_group_name=\"azure_resource_group.example.name\",\n    subscription_id=\"<MY_AZURE_SUBSCRIPTION_ID>\",\n)\ncontainer_instance_job.save(\"aci-dev\")\n```\n\nThen, create the deployment either on the UI or through the CLI:\n\n```bash\nprefect deployment build a_flow_module.py:log_hello_flow --name aci-dev -ib container-instance-job/aci-dev\n```\n\nVisit [Prefect Deployments](https://docs.prefect.io/latest/deploy/) for more information about deployments.\n\n## Azure Container Instance Worker\n\nThe Azure Container Instance worker is an excellent way to run\nyour workflows on Azure.\n\nTo get started, create an Azure Container Instances typed work pool:\n\n```\nprefect work-pool create -t azure-container-instance my-aci-work-pool\n```\n\nThen, run a worker that pulls jobs from the work pool:\n\n```\nprefect worker start -n my-aci-worker -p my-aci-work-pool\n```\n\nThe worker should automatically read the work pool's type and start an\nAzure Container Instance worker.\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Prefect integrations with Microsoft Azure services",
    "version": "0.4.2",
    "project_urls": {
        "Homepage": "https://github.com/PrefectHQ/prefect/tree/main/src/integrations/prefect-azure"
    },
    "split_keywords": [
        "prefect"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff550d43f9aecaa7d04fa9feab642c1fb000e34648fdea0ec9200f43a920938a",
                "md5": "97621ac6257eaaade1649b0fdde46135",
                "sha256": "8fc12b002091509c27fdf0a2be1b613cc3ced54540522800cda69809600b0713"
            },
            "downloads": -1,
            "filename": "prefect_azure-0.4.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "97621ac6257eaaade1649b0fdde46135",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 33874,
            "upload_time": "2024-11-20T17:07:42",
            "upload_time_iso_8601": "2024-11-20T17:07:42.667864Z",
            "url": "https://files.pythonhosted.org/packages/ff/55/0d43f9aecaa7d04fa9feab642c1fb000e34648fdea0ec9200f43a920938a/prefect_azure-0.4.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3a012acad3e636f0125a32719bc8f9f2f1435f04102b52112423c0b037c7bb63",
                "md5": "b09644706da24cd1b15bb1cdf621a79d",
                "sha256": "9b92655de05fa6f8197c965aaf9f942eaae8b4f68969d8d170b6b0da025e597b"
            },
            "downloads": -1,
            "filename": "prefect_azure-0.4.2.tar.gz",
            "has_sig": false,
            "md5_digest": "b09644706da24cd1b15bb1cdf621a79d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 46050,
            "upload_time": "2024-11-20T17:07:44",
            "upload_time_iso_8601": "2024-11-20T17:07:44.661286Z",
            "url": "https://files.pythonhosted.org/packages/3a/01/2acad3e636f0125a32719bc8f9f2f1435f04102b52112423c0b037c7bb63/prefect_azure-0.4.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-20 17:07:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PrefectHQ",
    "github_project": "prefect",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "prefect-azure"
}
        
Elapsed time: 0.68374s