Skip to content

Commit abaa633

Browse files
authored
Merge pull request #50817 from rloutlaw/rloutlaw/functions-quickfixes
Java functions quick content updates
2 parents acb4f4e + 8a259fb commit abaa633

File tree

2 files changed

+57
-6
lines changed

2 files changed

+57
-6
lines changed

articles/azure-functions/functions-create-first-java-maven.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,37 @@ curl -w '\n' -d AzureFunctionsTest https://fabrikam-functions-20170920120101928.
171171
Hello, AzureFunctionsTest
172172
```
173173

174+
## Make changes and redeploy
175+
176+
Edit the `src/main.../Function.java` source file in the generated project to alter the text returned by your Function app. Change this line:
177+
178+
```java
179+
return request.createResponse(200, "Hello, " + name);
180+
```
181+
182+
To the following:
183+
184+
```java
185+
return request.createResponse(200, "Hi, " + name);
186+
```
187+
188+
Save the changes and redeploy by running `azure-functions:deploy` from the terminal as before. The function app will be updated and this request:
189+
190+
```bash
191+
curl -w '\n' -d AzureFunctionsTest https://fabrikam-functions-20170920120101928.azurewebsites.net/api/HttpTrigger-Java
192+
```
193+
194+
Will have updated output:
195+
196+
```Output
197+
Hi, AzureFunctionsTest
198+
```
199+
174200
## Next steps
175201

176202
You've created a Java function app with a simple HTTP trigger and deployed it to Azure Functions.
177203

178204
- Review the [Java Functions developer guide](functions-reference-java.md) for more information on developing Java functions.
179205
- Add additional functions with different triggers to your project using the `azure-functions:add` Maven target.
180-
- Debug functions locally with Visual Studio Code. With the [Java extension pack](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack) installed and with your Functions project open in Visual Studio Code, [attach the debugger](https://code.visualstudio.com/Docs/editor/debugging#_launch-configurations) to port 5005. Then set a breakpoint in the editor and trigger your function while it's running locally:
181-
![Debug functions in Visual Studio Code](media/functions-create-java-maven/vscode-debug.png)
182-
- Debug functions remotely with Visual Studio Code. Check the [Writing serverless Java Applications](https://code.visualstudio.com/docs/java/java-serverless#_remote-debug-functions-running-in-the-cloud) documentation for instructions.
206+
- Write and debug functions locally with [Visual Studio Code](https://code.visualstudio.com/docs/java/java-azurefunctions), [IntelliJ](functions-create-maven-intellij.md), and [Eclipse](functions-create-maven-eclipse.md).
207+
- Debug functions deployed in Azure with Visual Studio Code. See the Visual Studio Code [serverless Java applications](https://code.visualstudio.com/docs/java/java-serverless#_remote-debug-functions-running-in-the-cloud) documentation for instructions.

articles/azure-functions/functions-reference-java.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ with the corresponding `function.json`:
8888

8989
Azure Functions supports the use of third-party libraries. By default, all dependencies specified in your project `pom.xml` file will be automatically bundled during the `mvn package` goal. For libraries not specified as dependencies in the `pom.xml` file, place them in a `lib` directory in the function's root directory. Dependencies placed in the `lib` directory will be added to the system class loader at runtime.
9090

91-
## Data Types
91+
## Data type support
9292

9393
You can use any data types in Java for the input and output data, including native types; customized Java types and specialized Azure types defined in `azure-functions-java-library` package. The Azure Functions runtime attempts convert the input received into the type requested by your code.
9494

@@ -238,7 +238,7 @@ public class MyClass {
238238

239239
Interact with Azure Functions execution environment via the `ExecutionContext` object defined in the `azure-functions-java-library` package. Use the `ExecutionContext` object to use invocation information and functions runtime information in your code.
240240

241-
### Logging
241+
### Custom logging
242242

243243
Access to the Functions runtime logger is available through the `ExecutionContext` object. This logger is tied to the Azure monitor and allows you to flag warnings and errors encountered during function execution.
244244

@@ -259,6 +259,29 @@ public class Function {
259259
}
260260
```
261261

262+
## View logs and trace
263+
264+
You can use the Azure CLI to stream Java standard out and error logging as well as other application logging. First, Configure your Function application to write application logging using the Azure CLI:
265+
266+
```azurecli-interactive
267+
az webapp log config --name functionname --resource-group myResourceGroup --application-logging true
268+
```
269+
270+
To stream logging output for your Function app using the Azure CLI, open a new command prompt, Bash, or Terminal session and enter the following command:
271+
272+
```azurecli-interactive
273+
az webapp log tail --name webappname --resource-group myResourceGroup
274+
```
275+
The [az webapp log tail](/cli/azure/webapp/log) command has options to filter output using the `--provider` option.
276+
277+
To download the log files as a single ZIP file using the Azure CLI, open a new command prompt, Bash, or Terminal session and enter the following command:
278+
279+
```azurecli-interactive
280+
az webapp log download --resource-group resourcegroupname --name functionappname
281+
```
282+
283+
You must have enabled file system logging in the Azure Portal or Azure CLI before running this command.
284+
262285
## Environment variables
263286

264287
Keep secret information such as keys or tokens out of your source code for security reasons. Use keys and tokens in your function code by reading them from environment variables.
@@ -283,9 +306,12 @@ Each key / value mapping in the `values` map will be made available at runtime a
283306
With your code now depending on these environment variables, you can sign in to the Azure portal to set the same key / value pairs in your function app settings, so that your code functions equivalently when testing locally and when deployed to Azure.
284307

285308
## Next steps
286-
For more information, see the following resources:
309+
310+
For more information about Azure Function Java development, see the following resources:
287311

288312
* [Best practices for Azure Functions](functions-best-practices.md)
289313
* [Azure Functions developer reference](functions-reference.md)
290314
* [Azure Functions triggers and bindings](functions-triggers-bindings.md)
315+
- Local development and debug with [Visual Studio Code](https://code.visualstudio.com/docs/java/java-azurefunctions), [IntelliJ](functions-create-maven-intellij.md), and [Eclipse](functions-create-maven-eclipse.md).
291316
* [Remote Debug Java Azure Functions with Visual Studio Code](https://code.visualstudio.com/docs/java/java-serverless#_remote-debug-functions-running-in-the-cloud)
317+
* [Maven plugin for Azure Functions](https://github.com/Microsoft/azure-maven-plugins/blob/develop/azure-functions-maven-plugin/README.md) - Streamline function creation through the `azure-functions:add` goal and prepare a staging directory for [ZIP file deployment](deployment-zip-push.md).

0 commit comments

Comments
 (0)