Skip to content

Commit 9c054bd

Browse files
author
Stefanus Hinardi
committed
Added some Acrolinx amendments
1 parent a974744 commit 9c054bd

File tree

1 file changed

+17
-33
lines changed

1 file changed

+17
-33
lines changed

articles/azure-functions/bring-dependency-to-functions.md

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ zone_pivot_groups: "bring-third-party-dependency-programming-functions"
88

99
# Bring dependencies or third party library to Azure Functions
1010

11-
In this article, you learn to bring in third-party dependencies, such as json files, binary files, and machine learning models, into your functions apps.
11+
In this article, you learn to bring in third-party dependencies into your functions apps. Examples of third-party dependencies are json files, binary files and machine learning models.
1212

1313
In this article, you learn how to:
1414
> [!div class="checklist"]
@@ -17,27 +17,10 @@ In this article, you learn how to:
1717
> [!div class="checklist"]
1818
> * Bring in dependencies via mounting Azure Fileshare
1919
::: zone-end
20-
## Prerequisites
21-
* An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio)
22-
* The Azure Functions Core Tools
23-
24-
* [Visual Studio Code](https://code.visualstudio.com/) on one of the [supported platforms](https://code.visualstudio.com/docs/supporting/requirements#_platforms)
25-
26-
* The [Azure Functions extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions) for Visual Studio Code.
27-
::: zone pivot="programming-language-python"
28-
* [Python versions that are supported by Azure Functions](supported-languages.md#languages-by-runtime-version)
29-
* Python Azure functions app deployed on Linux consumption plan. [Create your first Azure function in Python](./create-first-function-vs-code-python.md)
30-
::: zone-end
31-
::: zone pivot="programming-language-java"
32-
* The [Java Developer Kit](/azure/developer/java/fundamentals/java-jdk-long-term-support), version 8 or 11.
33-
* [Apache Maven](https://maven.apache.org), version 3.0 or above.
34-
* The [Java extension pack](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack)
35-
* Java Azure functions app deployed on Windows consumption plan. [Create your first Azure function in Java](./create-first-function-vs-code-java.md)
36-
::: zone-end
3720

3821
## Bring in dependencies from the project directory
3922
::: zone pivot="programming-language-python"
40-
One of the simplest ways to bring in dependencies is to put the files/artifact together with the functions app code in Functions project directory structure. Here is an example of the directory samples in a Python functions project:
23+
One of the simplest ways to bring in dependencies is to put the files/artifact together with the functions app code in Functions project directory structure. Here's an example of the directory samples in a Python functions project:
4124
```
4225
<project_root>/
4326
| - my_first_function/
@@ -50,11 +33,11 @@ One of the simplest ways to bring in dependencies is to put the files/artifact t
5033
| - host.json
5134
| - local.settings.json
5235
```
53-
By putting the dependencies in a folder inside functions app project directory, the dependencies folder will get deployed together with the code. This means that your function code will be able to access the dependencies in the cloud via file system api.
36+
By putting the dependencies in a folder inside functions app project directory, the dependencies folder will get deployed together with the code. As a result, your function code can access the dependencies in the cloud via file system api.
5437

5538
### Accessing the dependencies in your code
5639

57-
Here is an example to access and execute ```ffmpeg``` dependency that is put into ```<project_root>/ffmpeg_lib``` directory.
40+
Here's an example to access and execute ```ffmpeg``` dependency that is put into ```<project_root>/ffmpeg_lib``` directory.
5841

5942

6043
```python
@@ -88,7 +71,7 @@ def main(req: func.HttpRequest,
8871
::: zone-end
8972

9073
::: zone pivot="programming-language-java"
91-
One of the simplest ways to bring in dependencies is to put the files/artifact together with the functions app code in functions project directory structure. Here is an example of the directory samples in a Java functions project:
74+
One of the simplest ways to bring in dependencies is to put the files/artifact together with the functions app code in functions project directory structure. Here's an example of the directory samples in a Java functions project:
9275
```
9376
<project_root>/
9477
| - src/
@@ -101,7 +84,7 @@ One of the simplest ways to bring in dependencies is to put the files/artifact t
10184
| - local.settings.json
10285
| - pom.xml
10386
```
104-
For java specifically, you need to specifically include the artifacts into the build/target folder when copying resources. Here is an example on how to do it in Maven:
87+
For java specifically, you need to specifically include the artifacts into the build/target folder when copying resources. Here's an example on how to do it in Maven:
10588

10689
```xml
10790
...
@@ -128,11 +111,11 @@ For java specifically, you need to specifically include the artifacts into the b
128111
</execution>
129112
...
130113
```
131-
By putting the dependencies in a folder inside functions app project directory, the dependencies folder will get deployed together with the code.This means that your function code will be able to access the dependencies in the cloud via file system api.
114+
By putting the dependencies in a folder inside functions app project directory, the dependencies folder will get deployed together with the code. As a result, your function code can access the dependencies in the cloud via file system api.
132115

133116
### Accessing the dependencies in your code
134117

135-
Here is an example to access and execute ```ffmpeg``` dependency that is put into ```<project_root>/ffmpeg_lib``` directory.
118+
Here's an example to access and execute ```ffmpeg``` dependency that is put into ```<project_root>/ffmpeg_lib``` directory.
136119

137120

138121
```java
@@ -186,9 +169,9 @@ public class Function {
186169

187170
When running your function app on Linux, there's another way to bring in third-party dependencies. Functions lets you mount a file share hosted in Azure Files. Consider this approach when you want to decouple dependencies or artifacts from your application code.
188171
189-
First, you need to create an Azure Storage Account. In the account, you also need to create file share in Azure files. To create these resources, please follow this [guide](../storage/files/storage-how-to-use-files-portal.md)
172+
First, you need to create an Azure Storage Account. In the account, you also need to create file share in Azure files. To create these resources, follow this [guide](../storage/files/storage-how-to-use-files-portal.md)
190173
191-
After the storage account and file share are created, use the [az webapp config storage-account add](/cli/azure/webapp/config/storage-account#az_webapp_config_storage_account_add) command to attach the file share to your functions app, as shown in the following example.
174+
After you created the storage account and file share, use the [az webapp config storage-account add](/cli/azure/webapp/config/storage-account#az_webapp_config_storage_account_add) command to attach the file share to your functions app, as shown in the following example.
192175
193176
```console
194177
az webapp config storage-account add \
@@ -210,9 +193,9 @@ az webapp config storage-account add \
210193
| custom-id | Any unique string |
211194
| storage-type | Only AzureFiles is supported currently |
212195
| share-name | Pre-existing share |
213-
| mount-path | Path at which the share will be accessible inside the container. Value has to be of the format `/dir-name` and it cannot start with `/home` |
196+
| mount-path | Path at which the share will be accessible inside the container. Value has to be of the format `/dir-name` and it can't start with `/home` |
214197

215-
Additional commands to modify/delete the file share configuration can be found [here](/cli/azure/webapp/config/storage-account#az-webapp-config-storage-account-update)
198+
More commands to modify/delete the file share configuration can be found [here](/cli/azure/webapp/config/storage-account#az-webapp-config-storage-account-update)
216199

217200

218201
### Uploading the dependencies to Azure Files
@@ -222,7 +205,7 @@ One option to upload your dependency into Azure Files is through Azure portal. R
222205

223206
### Accessing the dependencies in your code
224207

225-
After your dependencies are uploaded in the file share, you can access the dependencies from your code. The mounted share is available at the specified *mount-path*, such as ```/path/to/mount```. You can also access the target directory by using file system APIs.
208+
After your dependencies are uploaded in the file share, you can access the dependencies from your code. The mounted share is available at the specified *mount-path*, such as ```/path/to/mount```. You can access the target directory by using file system APIs.
226209

227210
The following example shows HTTP trigger code that accesses the `ffmpeg` library, which is stored in a mounted file share.
228211

@@ -250,7 +233,7 @@ def main(req: func.HttpRequest) -> func.HttpResponse:
250233
return func.HttpResponse("Unexpected exception happened when executing ffmpeg. Error message:" + str(e),status_code=200)
251234
```
252235

253-
When you deploy this code to a function app in Azure, you need to [create an app setting](functions-how-to-use-azure-function-app-settings.md#settings) with a key name of `FILE_SHARE_MOUNT_PATH` and value of the mounted file share path, which for this example is `/azure-files-share`. To do local debugging, you need to populate the `FILE_SHARE_MOUNT_PATH` with the file path where your dependencies are stored in your local machine. Here is an example to set `FILE_SHARE_MOUNT_PATH` using `local.settings.json`:
236+
When you deploy this code to a function app in Azure, you need to [create an app setting](functions-how-to-use-azure-function-app-settings.md#settings) with a key name of `FILE_SHARE_MOUNT_PATH` and value of the mounted file share path, which for this example is `/azure-files-share`. To do local debugging, you need to populate the `FILE_SHARE_MOUNT_PATH` with the file path where your dependencies are stored in your local machine. Here's an example to set `FILE_SHARE_MOUNT_PATH` using `local.settings.json`:
254237
255238
```json
256239
{
@@ -269,5 +252,6 @@ When you deploy this code to a function app in Azure, you need to [create an app
269252
270253
## Next steps
271254
272-
+ [Develop Functions in Visual Studio Code](functions-develop-vs-code.md)
273-
+ [Scale and hosting options](functions-scale.md)
255+
+ [Azure Functions Python developer guide](functions-reference-python.md)
256+
+ [Azure Functions Java developer guide](functions-reference-java.md)
257+
+ [Azure Functions developer reference](functions-reference.md)

0 commit comments

Comments
 (0)