We were experiencing timeouts the first time a function from a Function App was being called so we move from a normal to premium service plan as in theory you can have always a warmed instance ready to answer a call (based on this documentation).
The thing is that when trying to configure the functionality we cannot see the setting present in the documentation. This is our portal:
And this is the portal settings appearing in the documentation:
The functions are still timing out the first time they are called so we did not see any difference moving from a normal plan to the premium one. Are we missing something?
Didn't reproduce your problem, I can set the pre-warmed instances on my portal. But I have an idea to solve this problem.
Try to use powshell in Azure Cloud Shell to configure the pre-warmed instances of your function app instead of using portal:
az resource update -g <resource_group> -n <function_app_name>/config/web --set properties.preWarmedInstanceCount=<desired_prewarmed_count> --resource-type Microsoft.Web/sites
Test whether it can be setted. If can't, have a look of the error. This may be an error with the portal.
If you have doubts, please let me know.
Turns out that you need to modify the Function App settings while we were tweaking the Service Plan.
We have there the warmed instances setting but it is not having the expected result, we are still facing the timeouts we had with the normal Service Plan.
Related
We manage an Azure subscription operated by several countries. Each of them is quite independant about they can do (create/edit/remove resources). A guide of good practices has been sent to them, but we (security team) would like to ensure a set of NSG is systematically applied for every new subnet/vnet created.
Giving a look to Azure Triggers, I am not sure that subnet creation belongs to the auditable events. I also was told to give a look to Azure policy, but once again I am not sure this will match our expectations which are : For every new vnet/subnet, automatically apply a set of predefined NSG.
Do you have any idea about a solution for our need ?
I have done work like this in the past (not this exact issue) and the way I solved it was with an Azure Function that walked the subscription and looked for these kinds of issues. You could have the code run as a Managed Identity with Reader rights on the subscription to report issues, or as a Contributor to update the setting. Here's some code that shows how you could do this with PowerShell https://github.com/Azure/azure-policy/tree/master/samples/Network/enforce-nsg-on-subnet
You could consider using a Policy that has a DeployIfNotExists Action, to deploy an ARM template that contains all the data for the NSG. https://learn.microsoft.com/en-us/azure/governance/policy/samples/pattern-deploy-resources
You can get the ARM template by creating the NSG and getting the template:
GettingNSGTemplate
Note also that creating a subnet is audited, you can see it in the Activity Log for the VNet. See the screen shot.
AddingASubnet
Title basically says it all. I have a function app on a consumption plan that I need to put onto a P2V2. Is it possible to convert the consumption plan or do I need to just redeploy to a new resource group?
Try this:
Create new AppService plan
Open CloudShell (PowerShell)
Run commands
Select-AzureRmSubscription -SubscriptionId "[id]"
Set-AzureRmWebApp -Name "[function name]" -ResourceGroupName "[resource group]" -AppServicePlan "[new app service plan name]"
source: https://github.com/Azure/Azure-Functions/issues/155#issuecomment-619980271
To do vice-versa, move functions from App Service plan to a Consumption Plan, Use the Azure Resource Explorer:
Source: https://www.gitmemory.com/issue/Azure/Azure-Functions/155/747559677
I was able to move back my Function from App Service Plan to Consumption plan by using the https://resources.azure.com/ website.
Enter edit mode, find your Function App and change the following:
{
serverFarmId: "..../<your-consumption-app-service-name>"
...
// Scroll a bit down
sku: "Dynamic"
}
Update the resource and you are done.
Make sure that you turn Always On off in the App Service Plan settings before the resource update to make this work.
Great question MrRobot. Unfortunately, there is no official way to move your consumption based Function App into a dedicated App Service Plan (Basic, Standard, P2v2, etc.). You will have to redeploy your settings into a new Function App that was created using the dedicated hardware.
Please let me know if you have any further questions or concerns.
Edit: To add additional clarity, I'd suggest looking at this for information on how to easily copy your Function App.
Also, switching is available to some customers but the number of customer is so small due to the requirement that your app was deployed to a web space that supports P2v2, which again is a small group. For an example on switching, check here. If you're unable to create a P2v2 Function App in the resource group of your consumption based Function App, you are not likely eligible to use this solution and would need to manually deploy to a dedicated function app.
I am new to azure and i am exploring it now, as first step i created a free azure account and in that i created a Resource group and an App service to that resource group.
When i try to access the Url https://azurehome.azurewebsites.net/ its giving an error 'The service is unavailable.'
any help on this ?
Please follow this document to troubleshoot:
https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-http-502-http-503
By the way, this problem may be caused by the region you choose, trying to change the region may be effective. I'm using Central US and it works fine.
If it still doesn't resolve, please provide more information.
If you need support, you can click this link:
https://azure.microsoft.com/en-us/support/options/
In this issue:
Azure Functions - Event Hub not triggering Functions
I described a problem with syncing event hub triggers and I managed to find a solution by simply invoking 'syncfunctiontriggers' action with Azure CLI:
az resource invoke-action --resource-group <resourceGrouName> --action syncfunctiontriggers --name <functionAppName> --resource-type Microsoft.Web/sites
Unfortunately this stopped working since 5th June and triggers are not fired on with messages getting into event hub - even if I call this command above. I need to go to portal and open function apps to sync them again but for me it is not a feasible solution.
I need to have an automated way of creating whole resource group, containing event hub, function apps, storages. At best with the use of Azure CLI.
Has anybody found a workaround for it or is this problem known already to Azure's team?
In the meantime I have found a workaround that is not entering the azure's portal. Simply make a call to trigger's function app page, e.g.:
curl -s https://<function-app-name>.azurewebsites.net > /dev/null
And after that if I run E2E tests, event hub triggers start to work. However, as with previous workarounds that I'd used, I don't how long it might be valid.
I'm trying to build a small program to change the autoscale settings for our Azure WebApps, using the Microsoft.WindowsAzure.Management.Monitoring and Microsoft.WindowsAzure.Management.WebSites NuGet packages.
I have been roughly following the guide here.
However, we are interested in scaling WebApps / App Services rather than Cloud Services, so I am trying to use the same code to read the autoscale settings but providing a resource ID for our WebApp. I have already got the credentials required for making a connection (using a browser window popup for Active Directory authentication, but I understand we can use X.509 management certificates for non-interactive programs).
This is the request I'm trying to make. Credentials already established, and an exception is thrown earlier if they're not valid.
AutoscaleClient autoscaleClient = new AutoscaleClient(credentials);
var resourceId = AutoscaleResourceIdBuilder.BuildWebSiteResourceId(webspaceName: WebSpaceNames.NorthEuropeWebSpace, serverFarmName: "Default2");
AutoscaleSettingGetResponse get = autoscaleClient.Settings.Get(resourceId); // exception here
The WebApp (let's call it "MyWebApp") is part of an App Service Plan called "Default2" (Standard: 1 small), in a Resource Group called "WebDevResources", in the North Europe region. I expect that my problem is that I am using the wrong names to build the resourceId in the code - the naming conventions in the library don't map well onto what I can see in the Azure Portal.
I'm assuming that BuildWebSiteResourceId is the correct method to call, see MSDN documentation here.
However the two parameters it takes are webspaceName and serverFarmName, neither of which match anything in the Azure portal (or Google). I found another example which seemed to be using the WebApp's geo region for webSpaceName, so I've used the predefined value for North Europe where our app is hosted.
While trying to find the correct value for serverFarmName in the Azure Portal, I found the Resource ID for the App Service Plan, which looks like this:
/subscriptions/{subscription-guid}/resourceGroups/WebDevResources/providers/Microsoft.Web/serverfarms/Default2
That resource ID isn't valid for the call I'm trying to make, but it does support the idea that a 'serverfarm' is the same as an App Service Plan.
When I run the code, regardless of whether the resourceId parameters seem to be correct or garbage, I get this error response:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
{"Code":"SettingNotFound","Message":"Could not find the autoscale settings."}
</string>
So, how can I construct the correct resource ID for my WebApp or App Service Plan? Or alternatively, is there a different tree I should be barking up to programatially manage WebApp scaling?
Update:
The solution below got the info I wanted. I also found the Azure resource explorer at resources.azure.com extremely useful to browse existing resources and find the correct names. For example, the name for my autoscale settings is actually "Default2-WebDevResources", i.e. "{AppServicePlan}-{ResourceGroup}" which I wouldn't have expected.
There is a preview service https://resources.azure.com/ where you can inspect all your resources easily. If you search for autoscale in the UI you will easily find the settings for your resource. It will also show you how to call the relevant REST Api endpoint to read or update that resorce.
It's a great tool for revealing a lot of details for your deployed resources and it will actually give you an ARM template stub for the resource you are looking at.
And to answer your question, you could programmatically call the REST API from a client with updated settings for autoscale. The REST API is one way of doing this, the SDK another and PowerShell a third.
The guide which you're following is based on the Azure Service Management model, aka Classic mode, which is deprecated and only exists mainly for backward compatibility support.
You should use the latest
Microsoft.Azure.Insights nuget package for getting the autoscale settings.
Sample code using the nuget above is as below:
using Microsoft.Azure.Management.Insights;
using Microsoft.Rest;
//... Get necessary values for the required parameters
var client = new InsightsManagementClient(new TokenCredentials(token));
client.AutoscaleSettings.Get(resourceGroupName, autoScaleSettingName);
Besides, the autoscalesettings is a resource under the "Microsoft.Insights" provider and not under the "Microsoft.Web" provider, which explains why you are not able to find it with your serverfarm resourceId.
See the REST API Reference below for getting the autoscale settings.
GET
https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/microsoft.insights/autoscaleSettings/{autoscale-setting-name}?api-version={api-version}