Azure recently released a SaaS Table adapter for Azure functions. I know this feature is experimental with no documentation, but I'm trying to see if anyone has this working.
My bindings (function.json):
{
"bindings": [
{
"name": "data",
"type": "blobTrigger",
"direction": "in",
"path": "somePathToBlob",
"connection": "connectionName_STORAGE"
},
{
"type": "apiHubTable",
"name": "output",
"connection": "sql_SQL",
"direction": "out",
"tableName": "tblEventStage"
}
],
"disabled": false
}
Then in run.csx I have:
public static void Run(string data, ITable<EventRecord> output, TraceWriter log)
{
// add some records to the table
}
The function compiles successfully and then pops an alert message:
Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ProcessAppInsights'. Microsoft.Azure.WebJobs.Extensions.ApiHub: The attribute ApiHubTableAttribute indicates a table binding. The parameter type must be one of the following: Microsoft.Azure.ApiHub.ITable, Microsoft.Azure.WebJobs.IAsyncCollector. To bind to a table client do not specify a table name. To bind to an entity specify the entity identifier.
What am I doing wrong?
Found the solution - I was using System.Data.Linq ITable instead of ITable from Microsoft.Azure.ApiHub. I removed System.Data.Linq and added nuget package Microsoft Azure ApiHub SDK. This requires adding a file package.json:
{
"frameworks": {
"net46":{
"dependencies": {
"Microsoft.Azure.ApiHub.Sdk": "0.6.10-alpha"
}
}
}
}
Records can be inserted to the table using:
output.CreateEntityAsync(record);
Related
I'm writing CURD Angular 5 with .Net API Custom . Now I'm have a error with class Model custom in Angular 5
This is message error
Failed to compile.
./src/app/model/customer.model.ts
Module build failed: Error:
D:\Angular\Project\CustomerApp\CustomerApp\ClientApp\src\app\model\customer.model.ts is missing from
the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include'
property.
at AngularCompilerPlugin.getCompiledFile
This is my file tsconfig.app.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "es2015",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
I tried to edit file tsConfig.app.json with add src/**/*.ts in "exclude":
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "es2015",
"types": []`enter code here`
},
"exclude": [
"test.ts",
"**/*.spec.ts",
"src/**/*.ts"
]
}
But don't work . Help me please !!!
The first , my name file model is customer.model.ts
and import in component as below :
import { Customer } from '../../model/customer.model';
Then I change name of file model to customer.ts
and import in component change to :
import { Customer } from '../../model/customer';
Now it's working good .
I am trying to deploy a virtual machine in azure via JSON using as much as possible JSON templates and parameters, when i try to generate an extension for the VM i get the error:
"VMExtensionProvisioningError"
with the message:
"Failed to decode, decrypt, and deserialize the protected settings string. Error Message: Keyset does not exist"
And i dont know what this stands for.
{
"apiVersion": "2017-12-01",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
],
"location": "[resourceGroup().location]",
"name": "[concat(parameters('virtualMachineName'),'/CustomScriptExtension')]",
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.7",
"autoUpgradeMinorVersion" : true,
"settings": {
"fileUris": [
"https://{storageAccountName}.blob.core.windows.net/scripts/{scriptName}"
],
"commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -file "{scriptName}" ')]"
},
"protectedSettings": { "storageAccountName": "[parameters('storageAccountName')]" }
},
"type": "Microsoft.Compute/virtualMachines/extensions"
},
What i am trying is to execute a script obtained from a blob in Azure.
What i am doing wrong?
I have a python function with a servicebus trigger and a blob input binding. The name of the blob match the content of the queue message.
My function.json file looks like that:
{
"bindings": [
{
"type": "serviceBusTrigger",
"name": "inputMessage",
"connection": "Omnibus_Validation_Listen_Servicebus",
"queueName": "validation-input-queue",
"accessRights": "listen",
"direction": "in"
},
{
"type": "blob",
"name": "inputBlob",
"path": "baselines/{inputMessage}",
"connection": "Omnibus_Blob_Storage",
"direction": "in"
}
],
"disabled": false
}
And it is working like a charm.
I'd to create a C# function with the same bindings but it does not seem to work.
I've used the same function.json file.
I have a project.json file:
{
"frameworks": {
"net46": {
"dependencies": {
"WindowsAzure.Storage": "8.5.0"
}
}
}
}
and my run.csx file looks like that:
public static void Run(string inputMessage, Stream inputBlob, TraceWriter log)
{
log.Info($"C# ServiceBus queue trigger function processed message: {inputMessage}");
}
When I save/run the function, I received this error:
Function ($import-baseline) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.import-baseline'. Microsoft.Azure.WebJobs.Host: No binding parameter exists for 'inputMessage'.
Is there any difference between the python and c# sdk for this kind of binding ?
I also can reproduce it on my side if I bind input blob path with baselines\{serviceBusTrigger} or baselines\{inputMessage} in the function.json file.
I am not sure whether it is supported to integrated input servicebus queue and input blob currently. We could give our feedback to Azure function team.
If Azure storage queue is acceptable we could use Azure storage queue trigger to do that. I test it on my side, it works correctly.
run.csx file
using System;
using System.Threading.Tasks;
public static void Run(string myQueueItem, Stream inputBlob, TraceWriter log)
{
log.Info($"C# storage queue trigger function processed message: {myQueueItem}");
StreamReader reader = new StreamReader(inputBlob);
string text = reader.ReadToEnd();
log.Info(text);
}
function.json
{
"bindings": [
{
"type": "blob",
"name": "inputBlob",
"path": "incontainer/{queueTrigger}",
"connection": "testweblog_STORAGE",
"direction": "in"
},
{
"type": "queueTrigger",
"name": "myQueueItem",
"queueName": "myqueue",
"connection": "testweblog_STORAGE",
"direction": "in"
}
],
"disabled": false
}
I'm having an issue with my Azure function. The function cannot startup because a FunctionInvocationException is being thrown each time.
The inner exception being an InvalidOperationException with the below message:
PartitionKey must be supplied for this operation
I have two bindings in my function that connect to a Document DB, one is an in binding that retrieves a specific document from a collection, and the other is an out binding used for auditing.
These both work fine in my dev, qa, and uat environments it is only the production environment that is having an issue. Both collections (for the settings and the auditing) were created without a partition key, the same as every environment.
System.InvalidOperationException:
at Microsoft.Azure.Documents.Client.DocumentClient+d__347.MoveNext (Microsoft.Azure.Documents.Client, Version=1.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
Any ideas?
I've tried deleting and remaking the audit collection but that didn't work. I don't get why the other environments are fine, but this one isn't.
Edit:
The function.json
{
"scriptFile": "..\\bin\\Cso.Notification.Function.dll",
"entryPoint": "Cso.Notification.Function.Program.Run",
"disabled": false,
"bindings": [
{
"type": "httpTrigger",
"direction": "in",
"webHookType": "genericJson",
"name": "request",
"methods": [
"post"
]
},
{
"type": "documentDB",
"name": "subscriberSettings",
"databaseName": "CSO",
"collectionName": "Settings",
"id": "SubscriberSettings",
"connection": "CsoDocDb",
"direction": "in"
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"type": "documentDB",
"name": "collector",
"databaseName": "CSO",
"collectionName": "AuditJSON",
"connection": "CsoDocDb",
"direction": "out"
}
]
}
I've found an answer. One of the documents we were querying for an initial value (SubscriberSettings) was incorrectly setup with a PartitionKey.
Deleting the collection and remaking it without a partition key did the trick.
I came across multiple ways of connecting Azure Storage Blobs to Azure (like this one for example) Functions but all of them require me to use a BlockBlob type parameter in my Run function, therefore replacing the HTTPRequestMessage parameter I need. Is there a way to keep the HTTPRequestMessage parameter and connect to Azure Storage Blob?
Ultimately, I need to get a file reference from the blob to send to another service via Azure Function.
When I try to add more parameters to Run, the function compiles properly, but I am returned a 500 error. When I change the parameters back to two, it works properly. The only difference is the parameter and function.json to which I add a section resulting in the entire file looking like this :
{
"bindings": [
{
"authLevel": "function",
"name": "req",
"type": "httpTrigger",
"direction": "in",
"methods": [
"get",
"post"
]
},
{
"type": "blob",
"name": "myBlobbo",
"path": "mycontainer",
"connection": "value",
"direction": "inout"
},
{
"name": "$return",
"type": "http",
"direction": "out"
}
],
"disabled": false
}
// Alright, now the logs are telling me that I didn't specify a connection string, even though I have a local.settings.json file with this inside:
{
"ConnectionStrings":
{
"xyz": "DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=yyy;EndpointSuffix=core.windows.net"
}
}
I'm probably going to just connect manually via passing an URI to CloudBlobContainer and using a file stream or %TEMP% to pass the contents, but I still would very much like to know how to get this binding to work.
// I'm using Azure environment to develop the function.
Following example shows how to get blob content with HttpRequest (HttpTrigger, Blob input, Http out):
run.csx
using System.Net;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, string inputBlob, TraceWriter log)
{
log.Info("Blob content: " + inputBlob);
return req.CreateResponse(HttpStatusCode.OK, inputBlob);
}
functions.json
{
"bindings": [
{
"authLevel": "function",
"name": "req",
"type": "httpTrigger",
"direction": "in",
"methods": [
"get",
"post"
]
},
{
"name": "$return",
"type": "http",
"direction": "out"
},
{
"type": "blob",
"name": "inputBlob",
"path": "incontainer/myblob.txt",
"connection": "AzureWebJobsDashboard",
"direction": "in"
}
],
"disabled": false
}
storage:
AzureWebJobsDashboard: