I can't see proxies for Azure Function App - azure

I have created an azure function app in VS 2017.
i've included a proxies.json file and published the app.
However I can't see the proxies in the Azure portal.
All it says is:
Proxies (preview) (Read Only)
I have gone into function settings, and there are no settings to enable proxies. I think that was the old method, (not for developing the function in visual studio)
proxies.json looks like this:
{
"$schema": "http://json.schemastore.org/proxies",
"proxies": {
"user": {
"matchCondition": {
"methods": [ "GET" ],
"route": "/user/{user}"
},
"backendUri": "https://<mycontainer>.blob.core.windows.net/html/test.html/{user}"
}
}
}

Ok I figured it out....
the proxies.json file should have copy to output directory as "copy always" in the properties panel in VS.

Related

Azure function working in local but not after uploading to azure

I'm new with azure functions and azure as whole.
I'm using azure functions for interacting with a SignalR service for usage in a xamarin forms app. I borrowed the azure function code from docs.MSDocs on serverless signalR service
Worked well in local (tested the web client provided in the docs, And also a simple console app).
But when the function was moved to azure. Initially I faced CORS error fixed those and then faced 502. Could not debug or find the root cause. After few hours of browsing found that azure itself provides a template for signalR serverless connection.
Used the template, configured the app settings with signalR endpoints (I have set the app setting for AzureSignalRConnectionString).
Still facing 502 error, . How can I get it to work? Or How do I find out the root cause for the failure.
Negotiate function code:
index.js
module.exports = async function (context, req, connectionInfo) {
context.res.body = connectionInfo;
};
Function.json
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"methods": [
"post"
],
"name": "req"
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"type": "signalRConnectionInfo",
"name": "connectionInfo",
"hubName": "messaage",
"connectionStringSetting": "AzureSignalRConnectionString",
"direction": "in"
}
]
}
SignalR Service needs a URL to access Function App when you're using SignalR Service trigger binding.
The URL format: <Function_App_URL>/runtime/webhooks/signalr?code=<API_KEY>. Explanation: The Function_App_URL can be found on Function App's Overview page and The API_KEY is generated by Azure Function. You can get the API_KEY from signalr_extension in the App keys blade of Function App.
And if you are very new to this, here is a step by step article to follow: https://github.com/aspnet/AzureSignalR-samples/tree/master/samples/BidirectionChat

azure Function proxy is not working on Linux systems

I created an azure functions premium tier to be able to have proxies on it but when trying to add a proxy I cantThis is what im getting right now !!
As Bowman mentioned in the comments, Azure function based on Linux systems cannot edit proxy on the Azure portal.
You need to create a proxies.json locally and deploy it to the Azure portal. the proxies.json looks like this:
{
"$schema": "http://json.schemastore.org/proxies",
"proxies": {
"proxy1": {
"matchCondition": {
"methods": [ "GET" ],
"route": "/api/{test}"
},
"backendUri": "https://<AnotherApp>.azurewebsites.net/api/<FunctionName>"
}
}
}
Note:
proxies.json is located in the root of a function app directory. For more details, you can refer to this official documentation.

Timer-Trigger not showing in Azure

I am new to Azure so sorry if this does not make too much sense.
I created a function app in Azure that works when testing. I am trying to use Timer-Trigger to make this app run each morning. The issue I have is that Timer-Trigger Template is not available when I click add. I am going to
Home > Function App > "Choose My App Here" > Events
But Timer Trigger template does not show. Is it not possible to add timer-trigger to an existing function app?
Also tried
Home > Function App > "Choose My App Here" > Functions
but no luck here either.
But Timer Trigger template does not show. Is it not possible to add
timer-trigger to an existing function app?
First, all Azure function based on script language and Windows OS should be able to create directly on the Azure portal. (Linux OS can not).
Second, I don't recommend you to create trigger directly on portal. If it is just a test, it is no problem, if you want to develop Azure function, I recommend you to use VS Code to develop Azure function, after finish the develop you can publish it to the Azure function.
Develop Azure function with VS Code needs four things: Azure function core tools (I recommend you to use V3), Azure function extension of VS Code, language environment and related language debug extension.
You can follow below doc:
https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-node
Use this button to deploy:
Or use function core tools command to deploy:
func azure functionapp publish <FunctionAppName>
Or use web app zip deploy, ftp, git, anyway is ok, just upload local function app structure to azure function app physical path.
And the main structure of timer-trigger:
index.js
module.exports = async function (context, myTimer) {
var timeStamp = new Date().toISOString();
if (myTimer.isPastDue)
{
context.log('JavaScript is running late!');
}
context.log('JavaScript timer trigger function ran!', timeStamp);
};
function.json
{
"bindings": [
{
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "* * * * * *"
}
]
}
Below link will tell you the format of schedule:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=csharp#ncrontab-expressions
local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=0730bowmanwindow;AccountKey=xxxxxx;EndpointSuffix=core.windows.net",
"FUNCTIONS_WORKER_RUNTIME": "node"
}
}
host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
}

How to use nested values from secrets.json Azure's App Service Configuration

In my app's secrets.json file, I have the following section.
"Serilog": {
"WriteTo": [
{
"Name": "AzureTableStorage",
"Args": {
"storageTableName": "Logging",
"connectionString": "DefaultEndpointsProtocol=xxxxxxxxxxx"
}
}
]
}
I am attempting to deploy to Azure and have added the keys to my app service's configuration like this.
Serilog__WriteTo__Name
Serilog__WriteTo__Args__storageTableName
Serilog__WriteTo__Args__connectionString
However, the application will not start (just shows an errror: "If you are the application administrator, you can access the diagnostic resources.") if I use either of the two longer keys. I have another setting named CosmosConnectionSettings__ContainerName which works fine, so it seems to be a problem with the nesting rather than they key lengths.
The app service is configured to use Linux.
Is there a better way to approach this, and is this limitation documented anywhere?
I think it's not the nesting's fault.
I have test it on my side, here is my secrets.json file:
{
"Serilog": {
"WriteTo": {
"Name": "AzureTableStorage",
"Args": {
"storageBlobName": "1.jpg",
"connectionString": "DefaultEndpointsProtocol=https;AccountName=XXX;AccountKey=XXX;"
}
}
}
}
And I write the value to the endpoint page like this:
Here is the Appsettings in my configuration on portal:
The Appsettings I set works well on azure web app.
My suggestion is:
Check how you use the key AzureTableStorage and connectionString in your scripts.
Test your project on IIS. Actually if it works well on IIS, it should work well on Azure.

API to add properties to Azure Webapp Application settings

I have one web app running on a Azure appservice plan. The web app has a lot of settings defined in Application settings of the Web App. Now I want to replicate that web app with all its Application settings. I got the REST API to list down all the settings available for any web app (/api/settings). Although there is a POST call to add/update the settings , But it is not updating Application settings.
Is there any REST API to add/update the Application settings of Azure web app ?
Thanks,
Abhiram
Is there any REST API to add/update the Application settings of Azure web app ?
Yes, we could update the application setting with the following Update Application Settings REST API
Put https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resource group}/providers/Microsoft.Web/sites/{WebAppName}/config/appsettings?api-version=2016-08-01
Body
{
"id": "subscriptions/{subscriptionId}/resourceGroups/{resource group}/providers/Microsoft.Web/sites/{WebAppName}/config/appsettings",
"name": "appsettings",
"type": "Microsoft.Web/sites/config",
"location": "South Central US",
"tags": {
"hidden-related:/subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Web/serverfarms/tomfreePlan": "empty"
},
"properties": {
"WEBSITE_NODE_DEFAULT_VERSION": "6.9.1",
"Test1": "testValue1" //Added value
}
}
Note: we could use the following List Application Settings REST API post way to list the appsetting body.
Post https://management.azure.com/subscriptions/{subscription}/resourceGroups/CXP-{resourceGroup}/providers/Microsoft.Web/sites/{WebAppName}/config/appsettings/list?api-version=2016-08-01
To my knowledge, there is not. But have you considered scripting your Web App settings with an ARM template? This is exactly the kind of thing that ARM templates are intended for.
An example of the properties section of a Web App's ARM template that lets you script appSettings and connectionStrings is listed below:
"properties": {
"name": "YourWebAppsName",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', YourAppServicePlanName)]",
"siteConfig": {
"appSettings": [
{
"name": "someAppSettingKey",
"value": "someAppSettingValue"
},
{
"name": "someOtherAppSettingKey",
"value": "someOtherAppSettingValue"
}
],
"connectionStrings": [
{
"name": "defautlConnection",
"connectionString": "YourConnectionString",
"type": "2"
},
]
}
When you deploy an ARM template, Azure will ensure that the target resource's settings match what's specified in your template.
Visual Studio has a project type for developing and deploying these. It's the Azure Resource Group project type located under the Cloud node in the project templates.
As an added bonus, you can check these ARM templates into source control alongside your code.

Resources