You can see IntelliSense by typing image
in the code inside the method.
InputDocument.IsApproved = passesText;
Bool containsCat = true;
and replace them with three new lines:
(bool containsCat, string caption) = await PassesImageModerationAsync(image);
inputDocument.IsApproved = containsCat && passesText;
inputDocument.Caption = caption;
If you use AutoHotKey there's a Serverless.ahk
file in the Reset\assets
folder with Control+Shift+a
configured to paste these lines.
EmitCustomTelemetry
line.
Click the Run button to start debugging.
Switch to browser tab with your Reviews website open.
Now that your code changes are done, you can make sure this is all working. By setting a breakpoint you now debug this function locally, while still interacting with Azure Storage and CosmosDB. You’ve started debugging locally. Click on the+ Add Picture
button on the website. you can add a new photo that will add a message to the Storage queue and trigger the function running in Visual Studio. Try a photo that will fail image moderation (a photo without a cat).
Click on +Image
.
Select the dog image.
Click on Review textbox.
Enter a review text in the textbox (or enter ctrl+shift+b to paste review text if using AutoHotKey).
Click create, wait for image and Pending status to show.
Switch to Visual Studio
Given this is a cat review site our Function should fail anything that’s not a cat. And that should trigger our function with this new review. Once the breakpoint is hit, check out the values of queueInput, containsCat, and caption (not inputDocument.Caption).Click Continue button and switch back to website
This is the amazing part, that no other serverless platform offers: you can trigger off Azure events even when you're running locally. This is not an emulator or simulator, it’s the actual Azure Functions runtime on your local machine.The function triggered from the queue message that the website created, and you can see the queue contents right here. You can also see the result that comes back from Cognitive Services. It will even give you a caption of the picture you uploaded. The function also uses the binding to update the status of the document in CosmosDB.
After the function finishes executing, refresh the website page. It should show the result of the moderation as Rejected and a description of the picture. Switch back to Visual Studio If you're happy with the function code update, it's time to ship it! If you have Live Unit Tests going, check that the green unit tests ticks are there. Right click on project and select Publish. The unit tests would have automatically run again when you added the image moderation code. Let’s have a look at how easy you can publish and deploy the function. The easiest way to do this is to right click on my project and select Publish. If using VSTS you can cancel out of publish window, otherwise you can publish it directly from here in Visual Studio. Here you can decide to publish directly to an Azure Function that you already have created on Azure, or create a new one using the Publish wizard.If you and your team are leveraging Visual Studio Team Services, the best tool for teams to implement continuous delivery of any code to Azure, continue to the next section.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4