SOLVED

Azure Application Gateway with App Service

%3CLINGO-SUB%20id%3D%22lingo-sub-1324374%22%20slang%3D%22en-US%22%3EAzure%20Application%20Gateway%20with%20App%20Service%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1324374%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Community%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20someone%20help%20me%20in%20understanding%20that%20how%20scalability%26nbsp%3B%20is%20handled%20by%20APG%20on%20app%20service%20level.%20Let's%20take%20an%20example%2C%20we%20have%20an%20app%20service%20deployed%20and%20running%20with%20auto-scale%20enabled%20and%20the%20app%20service%20is%20configured%20with%20APG.%20How%20APG%20get%20to%20know%20how%20many%20instances%20of%20the%20app%20service%20are%20running%20considering%20the%20auto%20scale%20is%20enabled%20on%20the%20app%20service%20level.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3ETayyab%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1324374%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EApp%20Services%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EApplication%20Gateway%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EVirtual%20Network%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1324771%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Application%20Gateway%20with%20App%20Service%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1324771%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F168863%22%20target%3D%22_blank%22%3E%40Tayyab%20Suhail%3C%2FA%3E%2C%26nbsp%3Bwhen%20you%20configure%20App%20Service%20as%20a%20backend%20for%20AppGW%2C%20you%20are%20providing%20its%20URL%2C%20not%20the%20actual%20references%20to%20the%20App%20Service%20Plan%20instances.%20AppGW%20only%20knows%20a%20Web%20App%20URL%2C%20as%20much%20as%20any%20other%20HTTP%20client.%20Therefore%2C%20App%20Service%20scaling%20operations%20are%20transparent%20to%20AppGW%2C%20no%20matter%20you%20have%201%20or%2010%20instances.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1324826%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Application%20Gateway%20with%20App%20Service%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1324826%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F453722%22%20target%3D%22_blank%22%3E%40hspinto%3C%2FA%3E%2C%20Thanks%20for%20taking%20out%20time%20and%20adding%20details%20to%20it.%20It%20makes%20sense%20what%20you%20are%20saying%20so%20i%20am%20wondering%20that%20APG%20provides%20session%20affinity%20feature%20that%20routes%20request%20coming%20from%20same%20client%20to%20the%20same%20instance%20of%20the%20application.%20In%20case%20there%20are%2010%20app%20service%20instance%20running%20how%20this%20session%20affinity%20thing%20is%20taken%20care%20considering%20the%20APG%20does%20not%20about%20how%20many%20instances%20are%20running%20and%20simply%20direct%20the%20traffic%20to%20the%20Web%20APP%20URL.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20hope%20i%20was%20able%20to%20communicate%20properly%20what%20i%20wanted%20to%20ask.%3CBR%20%2F%3E%3CBR%20%2F%3EMany%20Thanks%2C%3CBR%20%2F%3ETayyab%20Suhail%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1324947%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Application%20Gateway%20with%20App%20Service%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1324947%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F168863%22%20target%3D%22_blank%22%3E%40Tayyab%20Suhail%3C%2FA%3E%2C%26nbsp%3BAzure%20App%20Service%20honors%20ARRAffinity%2C%20so%2C%20even%20with%20AppGW%20in%20front%20of%20it%2C%20App%20Service%20%22load%20balancer%22%20should%20keep%20sending%20session-affinity-based%20requests%20to%20the%20same%20backend%20instance.%20However%2C%20take%20into%20account%20that%20App%20Service%20may%20be%20responding%20to%20requests%20with%20a%20different%20%22Location%22%20header%2C%20which%20will%20break%20session%20affinity.%20Read%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapplication-gateway%2Ftroubleshoot-app-service-redirection-app-service-url%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ethis%20article%3C%2FA%3E%20for%20a%20description%20of%20the%20problem%20and%20possible%20solutions.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1324960%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Application%20Gateway%20with%20App%20Service%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1324960%22%20slang%3D%22en-US%22%3EThank%20you%20very%20much%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F453722%22%20target%3D%22_blank%22%3E%40hspinto%3C%2FA%3E%2C%20i%20will%20go%20through%20this%20link%20and%20get%20back%20to%20you%20in%20case%20of%20any%20questions.%20Appreciate%20your%20help!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1379144%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Application%20Gateway%20with%20App%20Service%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1379144%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F453722%22%20target%3D%22_blank%22%3E%40hspinto%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20once%20again%20for%20sharing%20the%20excellent%20article.%20The%20shared%20article%20answered%20my%20question%20however%20i%20am%20back%20again%20with%20new%20question%20and%20would%20like%20your%20expertise%20to%20get%20it%20answered.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFew%20months%20back%2C%20we%20transitioned%20Asp.net%20web%20application%20from%20IaaS%20to%20PaaS%20mode.%20Being%20on%20PaaS%2C%20we%20used%20Redis%20cache%20to%20maintain%20user's%20session%20so%20in%20case%20multiple%20instances%20are%20running%20of%20the%20app%2C%20we%20do%20not%20lose%20users's%20session.%20This%20was%20working%20fine%20but%20when%20we%20placed%20application%20behind%20APG%2C%20we%20started%20facing%20session%20issues%20which%20was%20highlighted%20in%20the%20article%20that%20you%20shared.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20issue%20got%20resolved%20through%20ARRAfinity%20cookie%20feature%20but%20i%20am%20curious%20that%20why%20we%20faced%20this%20issue%20when%20placed%20application%20behind%20APG%2C%20considering%20we%20already%20used%20Redis%20to%20maintain%20user's%20session%20to%20avoid%20this%20kind%20of%20issue.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECould%20you%20please%20share%20your%20thoughts%20on%20it%20%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELet%20me%20know%20if%20you%20need%20more%20detail.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMany%20Thanks%2C%3C%2FP%3E%3CP%3ETayyab%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1381070%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Application%20Gateway%20with%20App%20Service%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1381070%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F168863%22%20target%3D%22_blank%22%3E%40Tayyab%20Suhail%3C%2FA%3E!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20don't%20know%20the%20details%20of%20how%20ASP.NET%20implements%20session%20management%20with%20Redis%2C%20but%20I%20guess%20the%20problem%20was%2C%20again%2C%20the%20Location%20header.%20If%20the%20Location%20header%20isn't%20rewritten%20by%20AppGW%20to%20the%20domain%20name%20of%20who's%20serving%20the%20request%2C%20then%20cookies%20will%20be%20cleared%20by%20the%20browser%20and%20you'll%20have%20no%20way%20of%20telling%20ASP.NET%20how%20to%20look%20for%20the%20session%20in%20Redis.%20Does%20it%20make%20sense%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1387311%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Application%20Gateway%20with%20App%20Service%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1387311%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F453722%22%20target%3D%22_blank%22%3E%40hspinto%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20taking%20out%20time%20to%20reply%20my%20question.%20Yes%2C%20it%20makes%20sense%20what%20you%20are%20saying%20and%20i%20will%20explore%20further%20with%20respect%20to%20Asp.Net%20and%20Redis.%20if%20i%20find%20some%20useful%20information%2C%20i%20will%20definitely%20share%20with%20you%20and%20the%20community.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOnce%20again%2C%20thanks.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3ETayyab%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Hi Community,

 

Can someone help me in understanding that how scalability  is handled by APG on app service level. Let's take an example, we have an app service deployed and running with auto-scale enabled and the app service is configured with APG. How APG get to know how many instances of the app service are running considering the auto scale is enabled on the app service level.

 

Regards,

Tayyab

7 Replies
best response confirmed by hspinto (Microsoft)
Solution

@Tayyab Suhail, when you configure App Service as a backend for AppGW, you are providing its URL, not the actual references to the App Service Plan instances. AppGW only knows a Web App URL, as much as any other HTTP client. Therefore, App Service scaling operations are transparent to AppGW, no matter you have 1 or 10 instances.

@hspinto, Thanks for taking out time and adding details to it. It makes sense what you are saying so i am wondering that APG provides session affinity feature that routes request coming from same client to the same instance of the application. In case there are 10 app service instance running how this session affinity thing is taken care considering the APG does not about how many instances are running and simply direct the traffic to the Web APP URL.

I hope i was able to communicate properly what i wanted to ask.

Many Thanks,
Tayyab Suhail

@Tayyab Suhail, Azure App Service honors ARRAffinity, so, even with AppGW in front of it, App Service "load balancer" should keep sending session-affinity-based requests to the same backend instance. However, take into account that App Service may be responding to requests with a different "Location" header, which will break session affinity. Read this article for a description of the problem and possible solutions.

Thank you very much @hspinto, i will go through this link and get back to you in case of any questions. Appreciate your help!

@hspinto 

 

Thank you once again for sharing the excellent article. The shared article answered my question however i am back again with new question and would like your expertise to get it answered.

 

Few months back, we transitioned Asp.net web application from IaaS to PaaS mode. Being on PaaS, we used Redis cache to maintain user's session so in case multiple instances are running of the app, we do not lose users's session. This was working fine but when we placed application behind APG, we started facing session issues which was highlighted in the article that you shared.

 

The issue got resolved through ARRAfinity cookie feature but i am curious that why we faced this issue when placed application behind APG, considering we already used Redis to maintain user's session to avoid this kind of issue. 

 

Could you please share your thoughts on it ? 

 

Let me know if you need more detail.

 

Many Thanks,

Tayyab

Hi, @Tayyab Suhail!

 

I don't know the details of how ASP.NET implements session management with Redis, but I guess the problem was, again, the Location header. If the Location header isn't rewritten by AppGW to the domain name of who's serving the request, then cookies will be cleared by the browser and you'll have no way of telling ASP.NET how to look for the session in Redis. Does it make sense?

@hspinto 

 

Thank you for taking out time to reply my question. Yes, it makes sense what you are saying and i will explore further with respect to Asp.Net and Redis. if i find some useful information, i will definitely share with you and the community.

 

Once again, thanks.

 

Regards,

Tayyab