I ran into this today as well on Azure Functions with NH 4.1.1.4000. It doesn't seem to happen on my older apps still on NH 3.x, mainly because this alias length check is not there.
Azure Functions doesn't really have the concept of host-level startup and shut down (they are supposed to be "run-once" and stateless, though this leaks out from time to time), so we end up creating a new SessionFactory on each invocation. Perusing the NHibernate source, it looks like there's a ThreadStatic tableCounter variable that is incremented when the constructor for the Table class is called. Wonderful.
Suspecting this may have something to do with it, I wrote a console app that iterated through creating 100 session factories and watching the queries it produced in NHProf, and sure enough the aliases get longer and longer because uniqueInteger climbs higher and higher. Then you explode at some point because the alias is too long.
Even the Azure Functions like you to pretend that you're running stateless, there is still a host process, and the threads that you run on may get recycled. So if you keep creating SessionFactory instances over and over -- which you aren't supposed to do, and typically don't in a typical web app, but you end up doing in a serverless framework like Azure Functions -- you will get this climbing alias length.
Subclassing MsSql2012Dialect in my case and setting MaxAliasLength to 128 works as a temporary band-aid. But the real workaround is to just stop instancing so many SessionFactories. I moved it to a static variable to ensure that it's only instanced once, even though my Autofac container is getting rebuilt every time Azure Functions invokes my code. I hope this helps someone.
Nicholas Piasecki