Azure autoscaling based on length of queue - azure

I want to autoscale my azure worker role based on the length of an azure queue. According to all the documentation I've seen this should be very straightforward, using the queueLength operand.
I've implemented the autoscaler, uploaded it to my service and added a bunch of elements to my queue, but the number of instances are not increasing.
What's the best way of troubleshooting? I've remote desktopped to the role and there isn't anything in the event log. Is there a log of autoscaling events/errors I can check?
Edit:
When I run the app in my dev environment, I see that the autscaler has successfully loaded the ServiceInfo.xml. There is a queue entry and a role entry. However, the rules don't appear to have been loaded out of the rules.xml file.
More edit:
When I removed the reactiverules and operands nodes from the rules.xml file, the constraint rule loads successfully. So the problem is in one of those nodes.
My serviceinfo xml file:
<?xml version="1.0" encoding="utf-8"?>
<serviceModel xmlns="http://schemas.microsoft.com/practices/2011/entlib/autoscaling/serviceModel">
<subscriptions>
<subscription name="MySubscription" subscriptionId="blah" certificateThumbprint="‎blah" certificateStoreName="My" certificateStoreLocation="CurrentUser">
<storageAccounts>
<storageAccount alias="targetstorage" connectionString="DefaultEndpointsProtocol=https;AccountName=blah; AccountKey="blah">
<queues>
<queue alias="auditqueue" queueName="auditqueue"/>
</queues>
</storageAccount>
</storageAccounts>
<services>
<service dnsPrefix="blah" slot="Production" scalingMode="Scale">
<roles>
<role alias="ScalingWebRole" roleName="ScalingWebRole" wadStorageAccountName="targetstorage" />
</roles>
</service>
</services>
</subscription>
</subscriptions>
</serviceModel>
My rules xml file:
<constraintRules>
<rule name="Default" enabled="true" rank="1">
<actions>
<range target="ScalingWebRole" min="1" max="10" />
</actions>
</rule>
</constraintRules>
<reactiveRules>
<rule name="Scale up when queue is long" enabled="true">
<actions>
<scale target="ScalingWebRole" by="1" />
</actions>
<when>
<greaterOrEqual operand="QueueLength_Avg" than="5" />
</when>
</rule>
<rule name="Scale down when queue is short" enabled="true">
<actions>
<scale target="ScalingWebRole" by="-1" />
</actions>
<when>
<less operand="QueueLength_Avg" than="5" />
</when>
</rule>
</reactiveRules>
<operands>
<queueLength alias="QueueLength_Avg" aggregate="Average" queue="auditqueue" timespan="00:01:00" />
</operands>
</rules>

Wasabi publishes a lot of diagnostic information, but you have to enable it. In the role where you are hosting the autoscaler, update the app.config to include the following:
<system.diagnostics>
<sources>
<source name="Autoscaling General" switchValue="All">
<listeners>
<add name="AzureDiag" />
</listeners>
</source>
<source name="Autoscaling Updates" switchValue="All">
<listeners>
<add name="AzureDiag" />
</listeners>
</source>
</sources>
<sharedListeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiag"/>
</sharedListeners>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
Then, if your role is configured to upload the log entries to the WADs table (Windows Azure Diagnostic table), you will see the entries there.
More info about the log entries that Wasabi generates here.

With the assistance provided by the diagnostics (thanks #Julian Dominguez), it became clear that the first time the autoscaling block was trying to hit the service (to check the queue length), it was failing. This is because the system was looking for the certificate in the CurrentUser store rather than the LocalMachine store.
Once I changed that setting in the configuration, it started to work.

Related

Asp.Net Core 2 (full framework) deployment to IIS creates an unwanted folder on the disk root

I have deployed a Asp.Net Core 2 app to IIS. The app is running fine but it keeps creating the following directory structure in the disk root:
D:\MYAPPNAME\MYAPPNAME\1.0.0
Even if i manually delete the folder, it gets created again when the app runs. What may cause this behaviour?
EDIT
After further investigation, i reproduced the issue using the VS 2017 template for asp-net core2 mvc application.
After adding Microsoft.Extensions.Logging.TraceSource nuget package and configuring the logs in app.config the unwated folder gets created...
This is the relevant part of the App.config
<system.diagnostics>
<sources>
<source name="TestApp" switchValue="All">
<listeners>
<clear />
<add name="RotatingFileLog" />
</listeners>
</source>
<source name="Microsoft" switchValue="All">
<listeners>
<clear />
<add name="RotatingFileLog" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="RotatingFileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter" logFileCreationSchedule="Daily" traceOutputOptions="DateTime" BaseFileName="test" location="Custom" CustomLocation="E:\logs\test\" Delimiter="|" AutoFlush="True" Append="True"></add>
</sharedListeners>
<trace autoflush="true" indentsize="4">
<listeners>
<clear />
<add name="RotatingFileLog" />
</listeners>
</trace>
</system.diagnostics>
It has turned out that Microsoft.VisualBasic.Logging.FileLogTraceListener was creating the folder. I switched to another listener, in this case Essential.Diagnostics.RollingFileTraceListener

Azure Diagnostic - Output TraceSource to Log Stream on Azure Portal

I'm trying to get trace output from a particular trace source onto Azure Portal's Log Stream. However, this does not seem to work
<system.diagnostics>
<sharedListeners>
<add name="txtListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="SchoolsDirectoryLog.log" />
</sharedListeners>
<sources>
<source name="SkyNet" switchName="sourceSwitch" switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="txtListener" />
</listeners>
</source>
</sources>
<switches>
<add name="sourceSwitch" value="Error, Information, Warning, Verbose" />
</switches>
</system.diagnostics>

cert missing when request arrive Azure web role

my works based on a azure web site using client certificate authenticate. it work with old cert. and i applied for a new cert and add it into request. but when request arrived Azure web role side. nothing can retrieved from request, my own code is not executed and return 403 directly.
i guess there is a issue with cert? i installed the cert in local machine, it work well in local. and install it into azure with .pfx and password. no change happened.
there is any other operates when install cert into azure?
does anyone can help me? pls
You need to share more details on what the exact error is. Start by figuring out, what the sub status code really is? whether it is 403.7 or 403.13 or something else
You can enable the logging for the site hosted on the web role and check what is the sub-status code (403.??).
Also you mentioned that the client is an Azure Web Site, so I guess you can enable System.Net tracing to gather more details and share it here. Add the following on the client web app's web.config.
<configuration>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.Net">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Cache">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Http">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.HttpListener">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Sockets">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.WebSockets">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="System.Net" type="System.Diagnostics.TextWriterTraceListener" initializeData="D:\home\LogFiles\System.Net.trace.log" traceOutputOptions = "ProcessId, DateTime" />
</sharedListeners>
<switches>
<add name="System.Net" value="Verbose" />
<add name="System.Net.Sockets" value="Verbose" />
<add name="System.Net.Http" value="Verbose"/>
<add name="System.Net.Cache" value="Verbose" />
<add name="System.Net.HttpListener" value="Verbose" />
<add name="System.Net.WebSockets" value="Verbose"/>
</switches>
<trace autoflush="true"/>
</system.diagnostics>
</configuration>

Windows Azure Auto Scale Application Block does not work and does not print log messages

I had implemented the Windows Azure Auto Scale Application Block in console application which monitor the performance counters and add the instances to the web role. I implemented the logging also but it does not show me the logs in the console and it does not adding the new instances to the web role based on rules.
And it is not giving me any error...
Without knowing how the application is configured (in particular the content of app.config and of the schedule file), the best educated guess I can make is that your app.config is missing the configuration in <system.diagnostics> to enable the logging of messages from the block.
In short, in your app.config you should have a section similar to the following (taken from one of my sample applications):
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="Autoscaling General" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="FileLog"/>
<remove name="Default" />
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
<source name="Autoscaling Updates" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="FileLog"/>
<remove name="Default" />
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information"/>
<add name="SourceSwitch" value="Verbose, Information, Warning, Error, Critical"/>
</switches>
<sharedListeners>
<add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter" location="ExecutableDirectory"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
You can find further information from MSDN.
In addition to his, I recall that I had to set some breakpoints (on Autoscaler.Start if I remind correctly) in order to catch some configuration errors.

Wasabi Azure constraint rules not enabled

I have a hosted service on Windows Azure and I am trying to use Wasabi Azure rules to affect scaling, however my rules are not being enforced. Both my rules.xml and serviceinformation-store.xml have been uploaded to my autoscaling Azure storage container. Here is my rules.xml
<rules xmlns="http://schemas.microsoft.com/practices/2011/entlib/autoscaling/rules" enabled="true">
<constraintRules>
<rule name="default" enabled="true" rank="1" description="The default constraint rule">
<timetable startDate="2012-11-05" startTime="05:34:00" utcOffset="-07:00" duration="02:00:00">
<daily/>
</timetable>
<actions>
<range min = "4" max="4" target="myWebService"/>
</actions>
</rule>
<rule name="ScaledownAtBusinessClose" enabled="true" rank="1" description="Scale down after hours">
<timetable startDate="2012-11-02" startTime="10:25:00" utcOffset="-07:00" duration="02:00:00">
<daily/>
</timetable>
<actions>
<range min ="1" max="1" target="myWebService" />
</actions>
</rule>
</constraintRules>
</rules>
Here is my service-information store
<serviceModel xmlns="http://schemas.microsoft.com/practices/2011/entlib/autoscaling/serviceModel">
<subscriptions>
<subscription name="Windows Azure MSDN - Visual Studio Ultimate" subscriptionId="<myid>" certificateThumbprint= "<mythumbprint>" certificateStoreName="My" certificateStoreLocation="CurrentUser" >
<services>
<service dnsPrefix="xxxxxxxxx" slot="Production" scalingMode="Scale">
<roles>
<role alias="myWebService" roleName="myWebService" wadStorageAccountName="<myaccount>"/>
</roles>
</service>
</services>
<storageAccounts>
<storageAccount alias="<myaccount>" connectionString="DefaultEndpointsProtocol=https;AccountName=<acctname>;AccountKey=<accountkey>">
<queues>
</queues>
</storageAccount>
</storageAccounts>
</subscription>
</subscriptions>
</serviceModel>
I start the web role with one instance but at 5:34 pm MST, the hosted service (myWebService) does not scale up to 4 instances.
In the project references I have Microsoft.WindowsAzure.Diagnostics, Microsoft.WindowsAzure.ServiceRuntime, Microsoft.WindowsAzure.StorageClient

Resources