Skip to content

Commit ee7505f

Browse files
authored
Merge pull request #309119 from v-thpra/lf-az-servconnect-005
Q&M: Light Freshness - Service Connector - 5
2 parents 8110428 + 8b20bc9 commit ee7505f

1 file changed

Lines changed: 27 additions & 27 deletions

File tree

articles/service-connector/tutorial-python-functions-storage-blob-as-input.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: 'Tutorial: Python function with Azure Blob Storage as input'
2+
title: 'Tutorial: Python Function with Azure Blob Storage as input'
33
description: Learn how you can connect a Python function to a storage blob as input using Service Connector in Azure.
44
author: houk-ms
55
ms.author: honc
66
ms.service: service-connector
77
ms.custom: devx-track-python
88
ms.topic: tutorial
9-
ms.date: 10/22/2024
9+
ms.date: 12/05/2025
1010
#customer intent: As a developer, I want to configure a Python function with Storage Blob as input function binding so that I can process and manage large volumes of data stored in Azure Blob Storage.
1111
---
1212
# Tutorial: Python function with Azure Blob Storage as input
@@ -26,12 +26,12 @@ An overview of the function project components in this tutorial:
2626
| ------------------------ | ------------------------------------ |
2727
| Source Service | Azure Function |
2828
| Target Service | Azure Storage Blob |
29-
| Function Binding | HTTP trigger, Storage Blob as Input |
29+
| Function Binding | HTTP trigger, Storage Blob as Input |
3030
| Local Project Auth Type | Connection String |
3131
| Cloud Function Auth Type | System-Assigned Managed Identity |
3232

3333
> [!WARNING]
34-
> Microsoft recommends that you use the most secure authentication flow available. The authentication flow described in this procedure requires a very high degree of trust in the application, and carries risks that are not present in other flows. You should only use this flow when other more secure flows, such as managed identities, aren't viable.
34+
> Microsoft recommends that you use the most secure authentication flow available. The authentication flow described in this procedure requires a high degree of trust in the application, and carries risks that aren't present in other flows. You should only use this flow when other more secure flows, such as managed identities, aren't viable.
3535
3636
## Prerequisites
3737

@@ -42,36 +42,36 @@ An overview of the function project components in this tutorial:
4242

4343
## Create a Python function project
4444

45-
Follow the [tutorial to create a local Azure Functions project](../azure-functions/how-to-create-function-vs-code.md?pivot=programming-language-python?pivots=python-mode-configuration#create-an-azure-functions-project), and provide the following information at the prompts:
45+
Follow the [tutorial to create a local Azure Functions project](../azure-functions/how-to-create-function-vs-code.md?pivot=programming-language-python?pivots=python-mode-configuration#create-an-azure-functions-project). Provide the following information at the prompts:
4646

4747
| Prompt | Selection |
4848
| --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
49-
| **Select a language** | Choose `Python`. (v1 programming language model) |
49+
| **Select a language** | Choose `Python`. (v1 programming language model) |
5050
| **Select a Python interpreter to create a virtual environment** | Choose your preferred Python interpreter. If an option isn't shown, type in the full path to your Python binary. |
51-
| **Select a template for your project's first function** | Choose `HTTP trigger`. |
52-
| **Provide a function name** | Enter `BlobStorageInputFunc`. |
53-
| **Authorization level** | Choose `Anonymous`, which lets anyone call your function endpoint.  |
51+
| **Select a template for your project's first function** | Choose `HTTP trigger`. |
52+
| **Provide a function name** | Enter `BlobStorageInputFunc`. |
53+
| **Authorization level** | Choose `Anonymous`, which lets anyone call your function endpoint.  |
5454

55-
You have created a Python function project with an HTTP trigger.
55+
With this information, Visual Studio Code generates a Python function project with an HTTP trigger.
5656

5757
## Add a Blob Storage input binding
5858

59-
Binding attributes are defined in the *function.json* file for a given function. To create a binding, right-click (Ctrl+click on macOS) the `function.json` file in your function folder and choose **Add binding...** . Follow the prompts to define the following binding properties for the new binding:
59+
Binding attributes are defined in the *function.json* file for a given function. To create a binding, right-click the `function.json` file in your function folder and choose **Add binding...**. Follow the prompts to define the following binding properties for the new binding:
6060

6161
| Prompt | Value | Description |
6262
| ------------------------------------------------------------------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
6363
| **Select binding direction** | `in` | The binding is an input binding. |
6464
| **Select binding with direction...** | `Azure Blob Storage` | The binding is an Azure Storage blob binding. |
6565
| **The name used to identify this binding in your code** | `inputBlob` | Name that identifies the binding parameter referenced in your code. |
6666
| **The path within your storage account from which the blob will be read** | `testcontainer/test.txt` | The blob path your function read as input. Prepare a file named `test.txt`, with a `Hello, World!` as the file content. Create a container named `testcontainer `, and upload the file to the container. |
67-
| **Select setting from "local.setting.json"** | `Create new local app settings` | Select the Storage Account your function reads as input. Visual Studio Code retrieves its connection string for local project connection. |
67+
| **Select setting from "local.setting.json"** | `Create new local app settings` | Select the Storage Account your function reads as input. Visual Studio Code retrieves its connection string for the local project connection. |
6868

6969
To check the binding was added successfully,
7070

71-
1. Open the `BlobStorageInputFunc/function.json` file, check that a new binding with `type: blob` and `direction: in` was added into this file.
72-
1. Open the `local.settings.json` file, check that a new key-value pair `<your-storage-account-name>_STORAGE: <your-storage-account-connection-string>` that contains your storage account connection string was added into this file.
71+
1. Open the `BlobStorageInputFunc/function.json` file, and check that a new binding with `type: blob` and `direction: in` was added into this file.
72+
1. Open the `local.settings.json` file, and check that a new key-value pair `<your-storage-account-name>_STORAGE: <your-storage-account-connection-string>` that contains your storage account connection string was added into this file.
7373

74-
After the binding is added, update your function codes to consume the binding by replacing `BlobStorageInputFunc/__init__.py` with the Python file here.
74+
After the binding is added, update your function code to consume the binding by replacing the `BlobStorageInputFunc/__init__.py` file with the following Python file:
7575

7676
```python
7777
import logging
@@ -86,17 +86,17 @@ def main(req: func.HttpRequest, inputBlob: bytes) -> func.HttpResponse:
8686

8787
Follow the [tutorial](../azure-functions/how-to-create-function-vs-code.md?pivot=programming-language-python?pivots=python-mode-configuration#run-the-function-locally) to run the function locally and verify the blob input.
8888

89-
1. Select the storage account you used when creating the Azure Function resource if you're prompted to connect to Storage. It is for Azure Function runtime's internal use, and isn't necessarily the same with the one you use for input.
90-
1. To start the function locally, press `<kbd>`F5 `</kbd>` or select the **Run and Debug** icon in the left-hand side Activity bar.
91-
1. To verify the function can read the blob, right click `Execute Function Now...` on the function in the Visual Studio Code **WORKSPACE** and check the function response. The response message should contain the content in your blob file.
89+
1. If you're prompted to connect to storage, select the storage account you chose when creating the Azure Function resource. This storage account is used for Azure Function's internal use, and isn't necessarily the same as the storage account you use for the input.
90+
1. To start the function locally, press <kbd>F5</kbd> or select the **Run and Debug** icon in the left-hand side Activity bar.
91+
1. To verify the function can read the blob, right-click `Execute Function Now...` on the function in the Visual Studio Code **WORKSPACE** and check the function response. The response message should contain the content in your blob file.
9292

9393
## Create a connection using Service Connector
9494

95-
You just ran the project and verified the function locally, and your local project connects to your storage blob using a connection string.
95+
In the last step, you ran the function locally and verified that your local project connects to your storage blob using a connection string.
9696

97-
Now you'll learn how to configure the connection between the Azure Function and Azure Blob Storage, so that your function can read the blob after being deployed to the cloud. In the cloud environment, we demonstrate how to authenticate using a system-assigned managed identity.
97+
Next, you learn how to configure the connection between the Azure Function and Azure Blob Storage. Once your function is deployed to the cloud, this connection allows your function to read the blob. Then, in the cloud environment, we demonstrate how to authenticate using a system-assigned managed identity.
9898

99-
1. Open the `function.json` file in your local project, change the value of the `connection` property in `bindings` to be `MyBlobInputConnection`.
99+
1. Open the `function.json` file in your local project, and change the value of the `connection` property in `bindings` to be `MyBlobInputConnection`.
100100
1. Run the following Azure CLI command to create a connection between your Azure Function and your Azure Storage.
101101

102102
```azurecli
@@ -106,24 +106,24 @@ az functionapp connection create storage-blob --source-id "<your-function-resour
106106
* `--source-id` format: `/subscriptions/{subscription}/resourceGroups/{source_resource_group}/providers/Microsoft.Web/sites/{site}`
107107
* `--target-id` format: `/subscriptions/{subscription}/resourceGroups/{target_resource_group}/providers/Microsoft.Storage/storageAccounts/{account}/blobServices/default`
108108

109-
You have created a connection between Azure Function and Azure Blob Storage using Service Connector, with a system-assigned managed identity.
109+
This step creates a connection between Azure Function and Azure Blob Storage using Service Connector, with a system-assigned managed identity.
110110

111111
Service Connector configured a `MyBlobInputConnection__serviceUri` variable in the function's app settings used by the function binding runtime to connect to the storage, so that the function can read data from the blob storage. You can learn more about [how Service Connector helps Azure Functions connect to services](./how-to-use-service-connector-in-function.md).
112112

113113
## Deploy your function to Azure
114114

115-
Now you can deploy your function to Azure and verify the storage blob input binding works.
115+
Now you can deploy your function to Azure and verify that the storage blob input binding works.
116116

117117
1. Follow the [tutorial](../azure-functions/how-to-create-function-vs-code.md?pivot=programming-language-python?pivots=python-mode-configuration#deploy-the-project-to-azure) to deploy your function to Azure.
118-
1. To verify the function can read the blob, right click `Execute Function Now...` on the function in the Visual Studio Code **RESOURCES** view and check the function response. The response message should contain the content in your blob file.
118+
1. To verify the function can read the blob, right-click `Execute Function Now...` on the function in the Visual Studio Code **RESOURCES** view and check the function response. The response message should contain the content in your blob file.
119119

120120
## Troubleshoot
121121

122-
If there are any errors related with storage host, such as `No such host is known (<account-name>.blob.core.windows.net:443)`, you need to check whether the connection string you use to connect to Azure Storage contains the blob endpoint or not. If it doesn't, go to Azure Storage in the Azure portal, copy the connection string from the `Access keys` blade, and replace the values.
122+
If there are any errors related with storage host, such as `No such host is known (<account-name>.blob.core.windows.net:443)`, you need to check whether the connection string you use to connect to Azure Storage contains the blob endpoint or not. If it doesn't, go to Azure Storage in the Azure portal, copy the connection string from the `Access keys` tab, and replace the values.
123123

124124
If the error happens when you start the project locally, check the `local.settings.json` file.
125125

126-
If the error happens when you deploy your function to cloud (in this case, Function deployment usually fails on `Syncing triggers` ), check your function's App Settings.
126+
If the error happens when you deploy your function to the cloud (in this case, function deployment usually fails on `Syncing triggers`), check your function's App Settings.
127127

128128
## Clean up resources
129129

@@ -146,7 +146,7 @@ az functionapp delete --name <function-name> --resource-group <resource-group>
146146

147147
## Next steps
148148

149-
Read the articles below to learn more about Service Connector concepts and how it helps Azure Functions connect to other cloud services.
149+
Read the following articles to learn more about Service Connector concepts and how it helps Azure Functions connect to other cloud services.
150150

151151
> [!div class="nextstepaction"]
152152
> [Learn about Service Connector concepts](./concept-service-connector-internals.md)

0 commit comments

Comments
 (0)