I'm trying to configure an Azure Table Storage output binding for an Azure Function (in JavaScript) using an identity-based connection instead of a connection string. I believe I've setup the Function as per the docs but I'm getting this error:
System.Private.CoreLib: Exception while executing function: Functions.AzureTvDataFetcher. Microsoft.Azure.WebJobs.Extensions.Storage: Storage account connection string 'AzureWebJobsAzuretvTableStorageConnection' does not exist. Make sure that it is a defined App Setting.
The error mentions that it should be a defined app setting, which it is. This is my local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "node",
"AzuretvTableStorageConnection__tableServiceUri": "https://<account-name>.table.core.windows.net"
}
}
And these are the triggers/bindings defined in function.json:
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"type": "table",
"tableName": "azuretv",
"name": "azuretvTableBinding",
"direction": "out",
"connection": "AzuretvTableStorageConnection"
}
]
}
The docs mention that it requires the extension bundle version 2.x, which is installed, see my host.json:
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[2.*, 3.0.0)"
},
So I'm not sure what I'm doing wrong. If I use a connection string instead it works fine. I've also deployed the Function app, created a managed identity for it and assigned the Storage Table Data Contributor role to the storage account but I still get the same error. Any ideas?
Related
I have an azure function that I want to send a message to a service bus that has a correlation filter on it. Specifically the correlation filter is on the label/subject with a value of 'APPLICATION'. correlation filter
How do I send the message from the azure function so that it will set this value and the subscription will receive the message?
Currently the function is set up something like this:
index.js:
module.exports = async function(context, inMessage) {
context.bindings.outMessage = someJavascriptObject;
}
function.json:
{
"bindings": [
{
"name": "inMessage",
"type": "serviceBusTrigger",
"direction": "in",
"topicName": "some_topic_1",
"subscriptionName": "SUBSCRIPTION_NAME",
"connection": "CONNECTION_STRING_1"
},
{
"name": "outMessage",
"type": "serviceBus",
"topicName": "some_topic_2",
"connection": "CONNECTION_STRING_2",
"direction": "out"
},
]
}
This is not currently supported. Please see https://github.com/Azure/azure-sdk-for-net/issues/21884
I have tested my Azure function to run locally and it works normally but after I deployed, it doesn't trigger whenever I upload a file in the video-temp container.
{
"bindings": [
{
"name": "myBlob",
"type": "blobTrigger",
"direction": "in",
"path": "video-temp/{name}",
"connection": "NewContainer"
}
],
"scriptFile": "../dist/VideoConversionTrigger/index.js"
}
this is my local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "node",
"NewContainer": "DefaultEndpointsProtocol=https; ..."
}
}
local.settings.json is only used on local. You need to add settings here after deploy:
And for the error, Microsoft.WindowsAzure.Storage: Requested value 'GET,HEAD,DELETE,MERGE,OPTIONS,POST,PUT,PATCH' was not found., you can break up the values into separate CORS entries.
I'm retrieving metrics from my Google Cloud Compute Engine instances with Node.js using this library.
I can create a time series with following result:
{
"points": [...],
"metric": {
"labels": {
"instance_name": "instance-1"
},
"type": "compute.googleapis.com/instance/cpu/usage_time"
},
"resource": {
"labels": {
"instance_id": "3123123123123412",
"zone": "europe-west1-d",
"project_id": "..."
},
"type": "gce_instance"
},
"metricKind": "DELTA",
"valueType": "DOUBLE",
"metadata": null
},
The problem is that it doesn't print the machine type (e.g. n1-standard-1) and/or number vCPUs, etc. Is it possible to change the request to all print machine type information?
Stackdriver metric responses will depend on the available fields on any given monitored resource. In this case, your request is getting all the information available to the gce_instance resource: project_id, instance_id, and zone.
The compute.googleapis.com/instance/cpu/* metric type is taken at the hypervisor level, not inside the instance, so it lacks more details. If you want to get information about the instance itself, you could install the Stackdriver Monitoring Agent on your instances, and change your metric type to the agent cpu metric: agent.googleapis.com/cpu/*
In this case, changing the metric type and maintaining usage_time would return cpu_number and cpu_state in addition to the other labels. I believe it would look something like this:
{
"points": [...],
"metric": {
"labels": {
"instance_name": "[INSTANCE_NAME]"
},
"type": "agent.googleapis.com/cpu/usage_time"
},
"resource": {
"labels": {
"instance_id": "[INSTANCE_ID]",
"zone": "[ZONE]",
"project_id": "[PROJECT_ID]",
"cpu_number": "[CPU_NUMBER]",
"cpu_state": "[CPU_STATE]"
},
"type": "gce_instance"
},
"metricKind": "CUMULATIVE",
"valueType": "INT64",
"metadata": null
},
Installing the agent would give you access to several other metric types, resources, and their resource labels. While I don't believe machine type is directly available, you should be able to get the rest of the information.
I'm trying to do a POST to the Strapi API and can't seem to figure out how to attach a 'has and belongs to many' (many to many) relationship.
I've already tried the following body's:
events: ["ID", "ID"]
name: "name"
&
events: [ID, ID]
name: "name"
Which regarding the docs should be right, I think.
There's no error, I get a '200 OK' response. It adds the record but without the relations.
Event.settings.json:
{
"connection": "default",
"collectionName": "events",
"info": {
"name": "event",
"description": ""
},
"options": {
"increments": true,
"timestamps": [
"created_at",
"updated_at"
],
"comment": ""
},
"attributes": {
"name": {
"type": "string"
},
"artists": {
"collection": "artist",
"via": "events",
"dominant": true
}
}
}
Artist.settings.json:
{
"connection": "default",
"collectionName": "artists",
"info": {
"name": "artist",
"description": ""
},
"options": {
"increments": true,
"timestamps": [
"created_at",
"updated_at"
],
"comment": ""
},
"attributes": {
"name": {
"required": true,
"type": "string"
},
"events": {
"collection": "event",
"via": "artists"
}
}
}
I'm using the standard SQLite database, strapi version 3.0.0-beta.13 and tried the request through Postman, HTML & curl.
I would love to know how to attach the relation on POST
Update 23-07:
Did a fresh install of Strapi and now everything is working.
I think it's because your set you ID as a String instead of an Integer
{
events: [1, 2],
name: "My name"
}
And here 1 and 2 are the IDs of events you want to add.
Late reply. Hoping this might help someone!
Right now I am using Strapi v4.3.2 and was facing the same issue. I overcame this by overriding the default core controller for create as explained in official docs. Relations are now visible!
async create(ctx) {
const { data } = ctx.request.body;
const response = await strapi.entityService.create(
"api::collection.collection",
{
data: data,
}
);
return {response}
}
This is (still? again?) a bug in Strapi, see: https://github.com/strapi/strapi/issues/12238
As a workaround you need to add the find-permission to the user / role who is performing the request for the related content type (you want to check first if this is a security issue for your scenario or not - alternatively you might want to try Paratron's approach which is described in the comments).
So, I've started playing with the Asterisk Restful Interface (ARI).
I have created a separate express app to do this.
I have a correctly configured instance of Asterisk 13 running. I know this because When I go to https://192.168.46.122:8088/ari/sounds in my browser, I am prompted for a username and password, which when entered, returns a valid JSON object back with the expected data...
[
{
"id": "conf-now-unmuted",
"text": "The conference is now unmuted.",
"formats": [
{
"language": "en",
"format": "gsm"
}
]
},
{
"id": "vm-nomore",
"text": "No more messages.",
"formats": [
{
"language": "en",
"format": "gsm"
}
]
},
{
"id": "vm-review",
"text": "press 1 to accept this recording press 2 to listen to it press 3 to rerecord your message",
"formats": [
{
"language": "en",
"format": "gsm"
}
]
},
{
"id": "demo-echodone",
"text": "The echo test has been completed.",
"formats": [
{
"language": "en",
"format": "gsm"
}
]
},
{
"id": "confbridge-rest-talk-vol-out",
"text": "...to reset your speaking volume to the default level.",
"formats": [
{
"language": "en",
"format": "gsm"
}
]
}, ...... etc etc
In my app.js file I have included the following code...
...
var logger = require('morgan');
var client = require('ari-client');
var url = 'https://192.168.46.122:8088/ari/sounds';
var username = 'correct_username';
var password = 'correct_password';
client.connect(url, username, password, function (err, ari) {
console.log('HELLLLLLOOOOO!!');
});
...
The issue, is that the anon callback is never fired. I never see 'HELLLLLLOOOOO!!'
Can anyone shed any light on why/under what circumstances this could happen? Are there any known bugs with the module that could be causing this?
Please let me know if you need further information about config, environment etc.
Thanks guys
UPDATE
Following comments below... I have tried the following:
client.connect(url, username, password)
.then(function(ari) {
console.log('HELLLLLLOOOOO!!');
})
.catch(function(err){
console.log('ERR: ' + err);
});
AND
client.connect(url, username, password, function (err, ari) {
if(err) console.log(err);
console.log('HELLLLLLOOOOO!!');
});
No error and no 'HELLLLLOOOOOO!!' at any point :-(
UPDATE 2
Have just visited /ari/api-docs/resources.json and got the following response... so it looks like it is present.
{
"_copyright": "Copyright (C) 2012 - 2013, Digium, Inc.",
"_author": "David M. Lee, II <dlee#digium.com>",
"_svn_revision": "$Revision: 430337 $",
"apiVersion": "1.7.0",
"swaggerVersion": "1.1",
"basePath": "http://192.168.46.122:8088/ari",
"apis": [
{
"path": "/api-docs/asterisk.{format}",
"description": "Asterisk resources"
},
{
"path": "/api-docs/endpoints.{format}",
"description": "Endpoint resources"
},
{
"path": "/api-docs/channels.{format}",
"description": "Channel resources"
},
{
"path": "/api-docs/bridges.{format}",
"description": "Bridge resources"
},
{
"path": "/api-docs/recordings.{format}",
"description": "Recording resources"
},
{
"path": "/api-docs/sounds.{format}",
"description": "Sound resources"
},
{
"path": "/api-docs/playbacks.{format}",
"description": "Playback control resources"
},
{
"path": "/api-docs/deviceStates.{format}",
"description": "Device state resources"
},
{
"path": "/api-docs/mailboxes.{format}",
"description": "Mailboxes resources"
},
{
"path": "/api-docs/events.{format}",
"description": "WebSocket resource"
},
{
"path": "/api-docs/applications.{format}",
"description": "Stasis application resources"
}
]
}
I'm now thinking it may be an SSL issue?!
Your connection is failing (for reasons outlined below), and because of an issue / upcoming-feature in node-ari-client, the failed connection is not logged.
The node-ari-client module uses Swagger, which expects to load a JSON schema describing an API. In the node-ari-client implementation, Swagger expects to find this JSON schema at %s//%s/ari/api-docs/resources.json.
So, the first thing to check is whether or not this exists / is accessible in your application:
https://192.168.46.122:8088/ari/api-docs/resources.json
There could be several reasons why this would not be available, but most likely the problem is authentication. You mention that when visiting your URL you are "prompted for a username and password". If your JSON schema (or any other files that need to be accessed without credentials) are behind authentication, you are going to need to rethink your application structure.
Currently, if there is a connection failure before Swagger has loaded the JSON schema, node-ari-client will fail silently. There is a Pull Request waiting which addresses this issue and would log the error, but in the meantime you should address the underlying issues which are preventing the connection.
If you can successfully access resources.json, there may be other issues with accessing resources. The URL you describe is accessing your service over https, but your resources.json file is telling Swagger to access it over regular http. To handle this, you could try:
Changing the basePath in your Swagger schema to use https:
"basePath": "https://192.168.46.122:8088/ari",
Adding a protocols field to your Swagger schema:
"protocols":["http", "https"]
Removing https
This is probably a good option in order to discover if https is the cause of the connection issue. Simply keep the Swagger schema exactly as is and try accessing / connecting to your services over http. Does this make a difference?