Running Azure functions with IoT Hub trigger - azure

I am trying to run an azure function locally in Visual Studio 2017 preview with latest tooling for azure functions. i want to know how to pull function.json as my function works on the azure portal but not locally in VS2017.
Looking forward on how to set iot hub connection endpoint settings in local.settings.json file.

In VS2017 tooling function.json file isn't created manually anymore. Instead, it's being generated at publish time from attributes that you put on your function parameters. In your case you will use EventHubTrigger attribute, see several examples in wiki.
Having an existing function.json, you should copy each property-value pair from the binding to the corresponding property of EventHubTrigger attribute. There's not automated way to do that.
local.settings.json is the container to put your app settings while running function locally from VS. They are just key-value pairs, go copy your settings from the portal if you have them there already. This file has no effect on deployment to Azure.

Related

How to utilize a .NET SDK inside Azure Function App?

I am trying to figure out how to utilize a .NET SDK into Azure Function.
What I am trying to do is pull data from a third party app called Sage's Intacct thru web service and push data into Azure SQL Server.
This is data flow:
(Sage's Intacct --> Azure Function --> Azure Data Factory --> Azure SQL Server).
I have a .NET Nuget SDK ( https://github.com/Intacct/intacct-sdk-net ), and I am using Visual Studio 2019 on my local machine and trying to publish into Azure Function.
This is URL for documentation.
I was able to install their .NET SDK Package inside FunctionApp solution.
I am trying to modify config file so I could grab data from Sage's Intacct thru web service (Http).
From other discussion thread, I got the tip that I probably need to use "HTTP Triggered Function".
Now, my challenge is, how do I utilize the Nuget package (Intacct.SDK) with Azure Function?
If I open a new solution file, I could see details of this package, but from here, I cannot publish cs file into Azure Function.
What is approach?
Thanks.
The workflow is a bit confuse, but you should be able to add Sage Intacct using Nuget:
https://www.nuget.org/packages/Intacct.SDK/
Then, it will be a dependency of your project which will be deployed together with you Azure Function code.

Is it possible to specify a container image to use when deploying Azure Functions from Visual Studio Code?

When creating an Azure Function using the Azure CLI, you can set a container image to use, with --deployment-container-image-name, documentation here.
Is it possible, using the highlighted "Deploy to Function App..." button or otherwise, to specify a container image when deploying a function in Visual Studio Code?
You run and deploy azure function in VS Code based on this plugin.
You can check, so it doesn't have this feature. You can first create the function app by command, and then use azure function plugin in VS Code to deploy.

Azure Function App Publish Target Missing in Visual Studio

I'm trying to publish an Azure Function to already deployed Azure Function App, which is in my subscription.
But Publish target for the Function app is missing.
This is a newly created Function and all other existing function has the publish target visible.
Do I need to configure something on the subscription side or the function .csproj to enable publish target?
One that has azure resource as publish target is running on 1.x runtime.
One that does not have azure resource as publish target is running on 2.x runtime
Adding reference to "Microsoft.NET.Sdk.Function" to note that it's an Azure Function fixed the issue.
For the latest version (VS20212 and Azure Function 3+) - adding references to Microsoft.NET.Sdk.Functions. There is one extra s in the package name. My article has added more details for reference:
Resolve - Azure Function App Publish Specific Target Not Existing in VS2019

upload json config file with azure functions?

I have Azure functions with configs (database connection strings, active directory, etc) set up for dev and live environments, right now I have everything in a class and I comment in/out the bits I'm using or not using.
Is there a way to upload a json file with the azure functions that will guide its config?
You mention "upload a json file" so I'm assuming that you're referring to some sort of release management activity. My suggestion is to simply use the built in AppSettings. Your use case is essentially what they are built for. Generally speaking if you store your settings within the appsettings of a function app and you have separate environments for your functions (dev & live) then you don't need to manage a separate json configuration file. The environment owns the configuration and your code will get the settings from the current environment.
If you have a more complex deployment and configuration management scenario I would consider using a release management tool such as VSTS to manage those configuration settings as part of the release pipeline so each environment has the correct settings at deployment time. Most CI\CD tools have functionality to update json configuration and\or update Azure App configuration directly.
Yes. You need to add connection strings as Application Settings. Azure Functions Core Tools uses local.settings.json file to read your connection strings when running locally and these settings are not pushed to Azure when published.

Azure Functions - Visual Studio Tools

I was trying to create Azure Functions as provided in the help link - https://blogs.msdn.microsoft.com/webdev/2016/12/01/visual-studio-tools-for-azure-functions/
I am actually creating a Evenhub trigger to write the messages to blob storage.
When I try to run the project, I am getting an error:
"Microsoft.Azure.WebJobs.Host: Error indexing method
'Functions.DashPOCEventHub'. Microsoft.WindowsAzure.Storage: Value
cannot be null."
I have put the correct values in the appsettings.json.
Can somebody help me with this error?
Also, when I try to publish the function to Azure, the appsettings.json is not being set correctly. I cannot see the values and keys when I go into the Azure UI application settings page.
appsettings.json won't create/override your web app ApplicationSettings when you deploy. You'll need to specify the ApplicationSettings for the web app explicitly.
The reason for this is so that you can use different secrets locally (appsettings.json) from what you deploy (web app appsettings).
There is more info on appsettings.json and web app Application Settings here.
Silly John, did you update the Azure CLI when you run your Function Locally? Today is on the Azure Functions Console CLI 1.0.0-beta.97.
Probably, this update solves this issue.

Resources