Home
%3CLINGO-SUB%20id%3D%22lingo-sub-1241650%22%20slang%3D%22en-US%22%3EIntegrating%20API%20Management%20with%20App%20Gateway%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1241650%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CU%3EIntegrating%20Application%20Gateway%20(v2)%20with%20API%20Management%20service%20in%20Internal%20Virtual%20network%20%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EUse%20Case%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EAPI%20Management%20service%20can%20be%20configured%20in%20Internal%20Virtual%20Network%20mode%20which%20makes%20it%20accessible%20only%20from%20within%20the%20Virtual%20Network.%20Using%20Application%20Gateway%20provides%20users%20the%20ability%20to%20protect%20the%20API%20Management%20service%20from%20OSWAP%20vulnerabilities.%20Application%20gateway%20is%20a%20reverse%20proxy%20service%20which%20has%20a%207-layer%20load%20balancer%20and%20provides%20Web%20Application%20Firewall%20(WAF)%20as%20one%20of%20the%20services%20in%20this%20use%20case.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EInternal%20Routing%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EIn%20this%20configuration%2C%20all%20the%20calls%20that%20hit%20the%20APIM%20Service%20pass%20through%20the%20Application%20Gateway.%20A%20blocker%20here%20could%20be%20that%20Application%20Gateway%20routes%20the%20calls%20using%20IP%20address%3B%20However%2C%20APIM%20works%20on%20the%20basis%20of%20host%20names.%20Since%20there%20is%20only%20one%20private%20IP%20designated%20to%20all%20the%20endpoints%20of%20APIM%20service%2C%20we%20need%20to%20configure%20Application%20Gateway%20in%20such%20a%20manner%20that%20the%20respective%20host%20name%20is%20supplied%20to%20the%20APIM%20internal%20load%20balancer%20as%20per%20the%20call%20that%20needs%20to%20be%20routed%20to%20the%20designated%20endpoint%20(portal%2C%20management%2C%20proxy%2C%20et%20cetera)%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EConfiguring%20the%20APIM%3C%2FSTRONG%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3ECreate%20an%20APIM%20Service%20following%20the%20steps%20explained%20in%20the%20below%20article%20%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapi-management%2Fget-started-create-service-instance%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapi-management%2Fget-started-create-service-instance%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3ECreate%20a%20Virtual%20network%20under%20your%20Azure%20Subscription.%20Use%20this%20same%20VNet%20to%20deploy%20the%20APIM%20service%20in%20Internal%20VNet%20mode.%3C%2FLI%3E%0A%3CLI%3EOnce%20configured%2C%20you%20would%20observe%20a%20Private%20IP%20for%20your%20APIM%20service%20on%20the%20Overview%20blade%20of%20the%20APIM%20Azure%20Portal.%20In%20this%20case%2C%20the%20private%20IP%20is%3CSTRONG%3E%2010.1.1.5%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22privateapim.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178424iFE993B7E087E98E1%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22privateapim.jpg%22%20alt%3D%22APIM%20in%20Private%20Vnet%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EAPIM%20in%20Private%20Vnet%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%20start%3D%224%22%3E%0A%3CLI%3EWhen%20the%20APIM%20service%20is%20in%20Internal%20VNet%20mode%20and%20the%20associated%20subnet%20has%20an%20NSG%20configured%2C%20there%20are%20certain%20network%20configurations%20that%20you%20need%20to%20add%20to%20the%20NSG%20associated%20to%20the%20subnet%20within%20which%20the%20APIM%20service%20resides.%3C%2FLI%3E%0A%3CLI%3EThe%20following%20public%20documentation%20highlights%20these%20in%20detail%20and%20specifies%20all%20the%20ports%20that%20you%20would%20need%20to%20set%20in%20order%20to%20enable%20accessibility%20to%20the%20APIM%20service%3A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapi-management%2Fapi-management-using-with-vnet%23-common-network-configuration-issues%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapi-management%2Fapi-management-using-with-vnet%23-common-network-configuration-issues%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ESetting%20up%20Custom%20Domains%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EWhen%20you%20create%20an%20Azure%20APIM%20service%2C%20Azure%20assigns%20it%20a%20subdomain%20of%26nbsp%3B%3CSTRONG%3Eazure-api.net%3C%2FSTRONG%3E%26nbsp%3B(for%20example%2C%26nbsp%3B%3CSTRONG%3Eapim-service-name.azure-api.net%3C%2FSTRONG%3E).%20However%2C%20you%20can%20also%20expose%20your%20APIM%20endpoints%20using%20your%20own%20custom%20domain%20name%2C%20such%20as%26nbsp%3B%3CSTRONG%3Exyz.com%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EUnder%20the%20Settings%20section%2C%20navigate%20to%20the%20%3CSTRONG%3ECustom%20Domains%3C%2FSTRONG%3E%20blade%20on%20your%20API%20Management%20service.%3C%2FLI%3E%0A%3CLI%3EAs%20you%20click%20the%20Add%20button%2C%20a%20new%20window%20would%20allow%20you%20to%20choose%20the%20type%20of%20endpoint%20along%20with%20the%20custom%20domain%20name%20you%20would%20like%20to%20configure.%3C%2FLI%3E%0A%3CLI%3EFor%20this%20setup%2C%20I%20have%20used%20the%20management%2C%20proxy%20and%20portal%20endpoints%20of%20the%20APIM%20service%20to%20be%20invoked%20with%20the%20highlighted%20hostname.%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22customdomains.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178425i22FFFE65C1EC1234%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22customdomains.jpg%22%20alt%3D%22Setting%20up%20Custom%20Domains%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ESetting%20up%20Custom%20Domains%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3EAs%20observed%2C%20when%20you%20add%20a%20custom%20domain%20with%20the%20preferred%20host%20name%2C%20you%20would%20need%20to%20furnish%20it%20with%20a%20valid%20%3CSTRONG%3E.pfx%3C%2FSTRONG%3E%20certificate%20associated%20to%20the%20host%20name.%3C%2FLI%3E%0A%3CLI%3EThe%20certificate%20to%20be%20used%20need%20to%20be%20different%20if%20you%20are%20using%20Application%20gateway%20version%20V1%20or%20V2%2C%20this%20document%20explains%20in%20detail%20about%20the%20difference%20in%20certificates%20to%20be%20used%20%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapplication-gateway%2Fcertificates-for-backend-authentication%23export-trusted-root-certificate-for-v2-sku%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapplication-gateway%2Fcertificates-for-backend-authentication%23export-trusted-root-certificate-for-v2-sku%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EWrapping%20it%20up%20as%20a%26nbsp%3B%20reference%20to%20above%20screenshot%2C%20Since%20I%20have%20been%3CSTRONG%3E%20using%20hostnames%20for%203%20different%20endpoints%20%2C%20%3CU%3EV2%20version%20would%20expect%20me%20to%20use%203%20different%20certificates%20in%20.pfx%20format%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3EYou%20can%20use%20any%20of%20the%20tools%26nbsp%3B%20like%20open%20ssl%20to%20create%20self-signed%20certificates.%20If%20you%20would%20like%20to%20do%20it%20using%20PowerShell%2C%20here%20is%20a%20%3CSTRONG%3Esample%20script%3C%2FSTRONG%3E%20that%20can%20come%20handy%20%3A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%23%20Create%20the%20root%20certificate%20for%20the%20self-signed%20certificate%3C%2FP%3E%0A%3CP%3E%24param1%20%3D%20%40%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20Subject%20%3D%20%22CN%3Dxyz%2C%20C%3DUS%22%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20KeyLength%20%3D%202048%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20KeyAlgorithm%20%3D%20'RSA'%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20HashAlgorithm%20%3D%20'SHA256'%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20KeyExportPolicy%20%3D%20'Exportable'%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20NotAfter%20%3D%20(Get-Date).AddYears(5)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20CertStoreLocation%20%3D%20'Cert%3A%5CLocalMachine%5CMy'%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20KeyUsage%20%3D%20'CertSign'%2C'CRLSign'%3C%2FP%3E%0A%3CP%3E%7D%3C%2FP%3E%0A%3CP%3E%24rootCA%20%3D%20New-SelfSignedCertificate%20%40param1%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%23%20Grab%20the%20thumbprint%20of%20the%20root%20certificate%3C%2FP%3E%0A%3CP%3E%24thumb%20%3D%20%24rootCA.Thumbprint%3C%2FP%3E%0A%3CP%3E%24root%20%3D%20Get-Item%20-Path%20Cert%3A%5CLocalMachine%5CMy%5C%24(%24thumb)%3C%2FP%3E%0A%3CP%3E%23This%20is%20a%20path%20you%20want%20to%20download%20the%20.cer%20of%20the%20root%20certificate.%3C%2FP%3E%0A%3CP%3E%24path%20%3D%20%22%3CADD%20your%3D%22%22%20local%3D%22%22%20path%3D%22%22%20here%3D%22%22%3E%22%3C%2FADD%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%23%20Export%20the%20root%20certificate%20in%20a%20Base64%20encoded%20X.509%20to%20the%20path%20created%20above%3C%2FP%3E%0A%3CP%3E%24base64certificate%20%3D%20%40%22%3C%2FP%3E%0A%3CP%3E-----BEGIN%20CERTIFICATE-----%3C%2FP%3E%0A%3CP%3E%24(%5BConvert%5D%3A%3AToBase64String(%24root.Export('Cert')%2C%20%5BSystem.Base64FormattingOptions%5D%3A%3AInsertLineBreaks)))%3C%2FP%3E%0A%3CP%3E-----END%20CERTIFICATE-----%3C%2FP%3E%0A%3CP%3E%22%40%3C%2FP%3E%0A%3CP%3ESet-Content%20-Path%20%24path%20-Value%20%24base64certificate%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%23%20Import%20the%20root%20certificate%20of%20the%20self-signed%20certificate%20to%20the%20local%20machine%20trusted%20root%20store%3C%2FP%3E%0A%3CP%3EImport-Certificate%20-CertStoreLocation%20'Cert%3A%5CCurrentUser%5CMy'%20-FilePath%20%22%3CUPDATE%20file%3D%22%22%20path%3D%22%22%20here%3D%22%22%3E%22%3C%2FUPDATE%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%23%20Create%20a%20new%20self-signed%20certificate%20and%20then%20link%20the%20root%20and%20the%20self-signed%20certificate%3C%2FP%3E%0A%3CP%3E%24param2%20%3D%20%40%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20DnsName%20%3D%20'*.azure-apim.net'%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Subject%20%3D%20%22management.azure-apim.net%22%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Signer%20%3D%20%24rootCA%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20KeyLength%20%3D%202048%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20KeyAlgorithm%20%3D%20'RSA'%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20HashAlgorithm%20%3D%20'SHA256'%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20KeyExportPolicy%20%3D%20'Exportable'%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20CertStoreLocation%20%3D%20'Cert%3A%5CLocalMachine%5CMy'%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20NotAfter%20%3D%20(Get-date).AddYears(2)%3C%2FP%3E%0A%3CP%3E%7D%3C%2FP%3E%0A%3CP%3E%24selfCert%20%3D%20New-SelfSignedCertificate%20%40param2%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%23%20Export%20the%20certificate%20in%20.pfx%20format%20for%20the%20application%20gateway%20listener%20and%20ASE%20ILB%20Cert.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EExport-PfxCertificate%20-Cert%20%24selfCert%20-FilePath%20%22%3CUPDATE%20file%3D%22%22%20path%3D%22%22%3E%22%20-Password%20(ConvertTo-SecureString%20-AsPlainText%20'%26lt%3B%20choose%20password%26gt%3B'%20-Force)%60%3C%2FUPDATE%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EAs%20highlighted%20in%20the%20PowerShell%20script%2C%20you%20would%20have%20to%20make%20the%20changes%20as%20per%20your%20local%20environment.%26nbsp%3B%20A%20sample%20file%20path%20that%20you%20could%20provide%20would%20look%20something%20like%20this%3A%20%E2%80%9CC%3A%5CUsers%5Ckwill%5Cmanagement.pfx%E2%80%9D%3C%2FLI%3E%0A%3CLI%3EThe%20subject%20part%20of%20the%20endpoint%20should%20change%20as%20per%20the%20endpoint%20you%20are%20using%20the%20certificate%20for.%20In%20this%20case%2C%20I%20have%20used%20the%20%3CSTRONG%3Emanagement%20endpoint%20%3C%2FSTRONG%3Esince%20I%20would%20use%20this%20certificate%20for%20creating%20custom%20domain%20for%20my%20management%20endpoint.%3C%2FLI%3E%0A%3CLI%3ERun%20this%20script%20for%20all%20the%20endpoints%20that%20you%20wish%20to%20be%20mapped.%20This%20should%20yield%20you%20different%20certificates%20associated%20to%20the%20host%20names.%3C%2FLI%3E%0A%3CLI%3EAnother%20thing%20worth%20mentioning%20is%20that%20if%20an%20APIM%20is%20configured%20to%20be%20in%20Internal%20VNet%20mode%2C%20it%20is%20expected%20to%20be%20running%20on%20its%20own%20custom%20DNS%20servers%2C%20and%20not%20Azure%20DNS.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSTRONG%3ESolving%20the%20issue%20for%20custom%20DNS%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ETo%20mimic%20the%20custom%20DNS%20servers%2C%20we%20would%20be%20using%20the%20Azure%3CSTRONG%3E%20Private%20DNS%20Zone%3C%2FSTRONG%3E%20offering.%3C%2FLI%3E%0A%3CLI%3EHere%20are%20the%20steps%20that%20you%20could%20follow%20to%20create%20Private%20DNS%20zone%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdns%2Fprivate-dns-getstarted-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdns%2Fprivate-dns-getstarted-portal%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EThe%20A%20records%20for%20the%20private%20DNS%20zones%20constitute%20the%20three%20endpoints%20of%20the%20APIM%20service%20pointing%20to%20the%20private%20IP%20of%20the%20service.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22privateDNS.jpg%22%20style%3D%22width%3A%20739px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178426iCDBA9BA1AAA0635E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22privateDNS.jpg%22%20alt%3D%22Configuring%20Private%20DNS%20zones%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EConfiguring%20Private%20DNS%20zones%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EOne%20key%20point%20to%20remember%20is%20the%20%3CSTRONG%3EPrivate%20DNS%20zone%20name%20should%20be%20a%20part%20of%20the%20FQDN%20for%20the%20host%20name.%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3EIn%20the%20above%20example.%20I%20have%20used%20the%20name%20as%20%3CSTRONG%3Eazure-apim.net%3C%2FSTRONG%3E%20%2C%20so%20that%20we%20can%20use%20all%20the%20endpoints%20as%20A%20records%20for%20the%20APIM%20Private%20IP.%3C%2FLI%3E%0A%3CLI%3ENavigate%20to%20the%20%3CSTRONG%3EVirtual%20Network%20Links%3C%2FSTRONG%3E%20blade%20of%20the%20private%20DNS%20Zone%20and%20link%20the%20Virtual%20Network.%20This%20would%20complete%20the%20setup%20for%20private%20DNS%20zones.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EAt%20this%20point%20of%20time%2C%20your%20APIM%20service%20has%20been%20configured%20to%20run%20inside%20a%20Virtual%20Network%20along%20with%20the%20custom%20domains.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ESetting%20up%20App%20Gateway%3C%2FSTRONG%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EYou%20can%20create%20the%20App%20Gateway%20using%20the%20steps%20explained%20in%20the%20below%20documentation%3A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapplication-gateway%2Fquick-create-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapplication-gateway%2Fquick-create-portal%3C%2FA%3E%3C%2FP%3E%0A%3COL%20start%3D%222%22%3E%0A%3CLI%3EThis%20article%20assumes%20that%20you%20have%20configured%20v2%20version%20for%20the%20App%20Gateway%20as%20we%20move%20along%20with%20the%20setup%20ahead.%3C%2FLI%3E%0A%3CLI%3EAs%20highlighted%20in%20the%20public%20documentation%20above%2C%20App%20Gateway%20has%20certain%20mandatory%20components%20that%20needs%20to%20be%20configured%20when%20we%20create%20it.%20We%20would%20be%20covering%20the%20details%20of%20the%20same%20below%3A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EBackend%20Pool%3A%3C%2FSTRONG%3E%20App%20Gateway%20needs%20at%20least%20one%20backend%20pool%20to%20be%20configured%20during%20creation.%20Use%20the%20%3CSTRONG%3Ecustom%20domain%20hostname%20%3C%2FSTRONG%3Eof%20the%20API%20Management%20instance%20to%20be%20configured%20in%20the%20backend%20pool%20section.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22backendpool.jpg%22%20style%3D%22width%3A%20629px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178427iEE0C4B4D5159CB67%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22backendpool.jpg%22%20alt%3D%22Backend%20Pool%20Configuration%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EBackend%20Pool%20Configuration%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EAs%20a%20reference%2C%20we%20would%20be%20starting%20with%20the%20management%20endpoint%20configuration%20for%20now.%20You%20can%20repeat%20the%20same%20steps%20for%20Proxy%20or%20Portal%20endpoints.%3C%2FLI%3E%0A%3CLI%3EWe%20would%20be%20using%20three%20different%20backend%20pools%20for%20all%20the%20custom%20domains%20that%20we%20had%20configured%20earlier.%3C%2FLI%3E%0A%3CLI%3EUse%20the%20custom%20domain%20hostname%20to%20be%20used%20as%20an%20FQDN%20in%20the%20backend%20pool.%20Let%20us%20call%20it%20%3CSTRONG%3Emanagementbackend.%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EHttpSettings%3C%2FSTRONG%3E%3A%20These%20are%20the%20settings%20which%20include%20the%20protocols%20and%20probes%20configuration%20that%20the%20Application%20Gateway%20would%20be%20using%20to%20connect%20to%20the%20backend%20host%20names%20of%20APIM%20service.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22httpsettings.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178428i9EFCCE49BF523C21%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22httpsettings.jpg%22%20alt%3D%22Adding%20Http%20Settings%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EAdding%20Http%20Settings%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ETo%20sync%20with%20the%20managementbackend(backend%20pool)%20highlighted%20in%20the%20previous%20step%2C%20we%20would%20go%20ahead%20and%20configure%20http%20settings%20called%20%3CSTRONG%3Emanagementhttp%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22addhttp.jpg%22%20style%3D%22width%3A%20789px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178429iED3A2A8ED1BD21F9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22addhttp.jpg%22%20alt%3D%22addhttp.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EImportant%20point%20to%20note%20here%20is%20that%3CSTRONG%3E%20the%20certificate%20to%20be%20added%20here%20has%20to%20be%20the%20root%20certificate%20(in%20.cer%20fomat)%20%3C%2FSTRONG%3Eof%20the%20%3CSTRONG%3E.pfx%3C%2FSTRONG%3E%20certificate%20that%20we%20created%20while%20creating%20the%20custom%20domains.%3C%2FLI%3E%0A%3CLI%3EIn%20a%20nutshell%2C%20I%20would%20use%20the%20management%20endpoint%20%3CSTRONG%3E.pfx%3C%2FSTRONG%3E%20certificate%20and%20export%20it%20to%20%3CSTRONG%3E.cer%3C%2FSTRONG%3E%20format.%20Later%2C%20we%20would%20need%20the%20root%20certificate%20of%20the%20exported%20certificate%20(in%20.cer%20format)%20to%20whitelist%20the%20management%20endpoint.%3C%2FLI%3E%0A%3CLI%3EKindly%20follow%20this%20documentation%20which%20contains%20a%20step-by-step%20demo%20for%20setting%20up%20certificates%20for%20v2%20version%20Application%20Gateway%3A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapplication-gateway%2Fcertificates-for-backend-authentication%23export-trusted-root-certificate-for-v2-sku%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapplication-gateway%2Fcertificates-for-backend-authentication%23export-trusted-root-certificate-for-v2-sku%3C%2FA%3E%20.%20This%20step%20is%20crucial%2C%20and%20not%20having%20a%20valid%20root%20certificate%20may%20result%20in%20Internal%20Server%20Errors%20while%20deploying%20the%20Application%20Gateway.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EAs%20we%20scroll%20down%2C%20we%20need%20to%20select%20%3CSTRONG%3EYes%3C%2FSTRONG%3E%20for%20%3CSTRONG%3EOverride%20with%20new%20host%20name%3C%2FSTRONG%3E%20and%20Click%20on%20%3CSTRONG%3EPick%20host%20name%20from%20backend%20target%3C%2FSTRONG%3E%20(since%20hostname%20has%20already%20been%20specified%20in%20the%20backend%20pool)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22addhttp1.jpg%22%20style%3D%22width%3A%20770px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178430iCB627154DE83C79A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22addhttp1.jpg%22%20alt%3D%22addhttp1.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThis%20would%20associate%20the%20Http%20settings%20to%20the%20backend%20pool%20that%20we%20created%20for%20the%20management%20endpoint.%3C%2FLI%3E%0A%3CLI%3EWe%20would%20need%20to%20configure%20different%20Http%20settings%20for%20different%20backend%20pools%20that%20we%20create%20(in%20case%20we%20need%20to%20add%20proxy%20and%20portal%20endpoint).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EHealth%20Probes%3A%3C%2FSTRONG%3E%20These%20are%20the%20probes%20that%20would%20constantly%20keep%20checking%20the%20connection%20between%20the%20Application%20Gateway%20and%20the%20APIM%20service%20and%20would%20set%20the%20backend%20health%20value%20as%20per%20the%20configuration%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22healthprobes.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178431iB5EBD56637250D0B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22healthprobes.jpg%22%20alt%3D%22healthprobes.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EAs%20observed%2C%20there%20would%20be%20multiple%20probes%20configured%20for%20multiple%20Http%20settings%20which%20would%20indicate%20the%20backend%20health%20for%20all%20the%20endpoints.%3C%2FLI%3E%0A%3CLI%3EIn%20case%20of%20proxy%20probe%2C%20%3CSTRONG%3E%2Fstatus%200123456789abcdef%20is%20a%20common%20health%20endpoint%20for%20the%20APIM%20service.%20%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EListeners%3A%3C%2FSTRONG%3E%20We%20would%20be%20configuring%20different%20Listeners%20for%20different%20hostnames%20which%20are%20to%20be%20used%20in%20the%20Application%20Gateway%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Listeners.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178432iA82BFA77382C9BE4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Listeners.jpg%22%20alt%3D%22Listeners.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EEach%20of%20the%20listener%20would%20have%20a%20rule%20configured%20along%20with%20the%20hostname%20that%20we%20would%20associate%20it%20to.%3C%2FLI%3E%0A%3CLI%3ERunning%20through%20the%20%3CSTRONG%3Emanagementlistener%3C%2FSTRONG%3E%20in%20this%20case%2C%20which%20has%20been%20setup%20to%20cater%20to%20the%20management%20hostname%3A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22mgmtlistener.jpg%22%20style%3D%22width%3A%20767px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178433i19CE735D3F076ACB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22mgmtlistener.jpg%22%20alt%3D%22mgmtlistener.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EPlease%20note%20that%20the%3CSTRONG%3E%20certificate%20should%20be%20the%20same%20certificate%20in%20.pfx%20format%20that%20we%20had%20used%20earlier%20to%20create%20the%20management%20endpoint%20custom%20domain%20in%20APIM%20instance.%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3ESince%20API%20management%20supports%20multiple%20endpoints%2C%20use%20a%20multi-site%20listener%20and%20add%20the%20associated%20hostname%20(which%20is%20the%20management%20hostname%20in%20this%20case)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3ERules%3A%3C%2FSTRONG%3E%20We%20need%20to%20add%20routing%20rules%20that%20would%20be%20associated%20to%20the%20listeners%20and%20would%20have%20the%20configuration%20of%20the%20backend%20pool.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Rules.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178434i9EB06AC62CBBF3CC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Rules.jpg%22%20alt%3D%22Rules.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EAdd%20the%20backend%20targets%20with%20the%20backend%20pool%20and%20the%20Http%20settings%20that%20we%20had%20created%20earlier%20for%20the%20management%20endpoint.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EBackend%20health%3C%2FSTRONG%3E%3A%20Backend%20health%20blade%20helps%20us%20verify%20whether%20the%20setup%20is%20working%20as%20expected.%20It%20would%20yield%20the%20results%20based%20on%20the%20probing%20checks%20of%20the%20health%20probes%20that%20we%20had%20previously%20configured%20for%20different%20end%20points.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22backendhealth.jpg%22%20style%3D%22width%3A%20883px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178436iED278ACCB709B283%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22backendhealth.jpg%22%20alt%3D%22backendhealth.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EA%20%3CSTRONG%3EHealthy%3C%2FSTRONG%3E%20status%20in%20the%20backend%20health%20indicates%20that%20the%20App%20Gateway%20is%20able%20to%20talk%20to%20the%20API%20management%20service.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3EValidating%20the%20setup%3C%2FSTRONG%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3ETo%20ensure%20that%20the%20setup%20is%20working%20as%20expected%2C%20we%20can%20try%20to%20browse%20any%20of%20the%20configured%20endpoints%20from%20the%20local%20machine.%3C%2FLI%3E%0A%3CLI%3EUpdate%20the%20host%20file%20from%20this%20location%20(%3CSTRONG%3EC%3A%5CWindows%5CSystem32%5Cdrivers%5Cetc%3C%2FSTRONG%3E)%20on%20the%20local%20machine%20with%20the%20following%20additional%20entries%20as%20per%20the%20required%20configuration%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22hostfile.jpg%22%20style%3D%22width%3A%20576px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178437iF0E6FD99A2F4D007%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22hostfile.jpg%22%20alt%3D%22hostfile.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EAs%20observed%2C%20we%20need%20to%20map%20the%20%3CSTRONG%3Epublic%20IP%20of%20the%20App%20Gateway%20to%20the%20hostname%20of%20the%20custom%20domains.%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3EWhen%20you%20attempt%20to%20browse%20any%20of%20these%20endpoints%20from%20the%20local%20machine%2C%20you%20should%20be%20able%20to%20successfully%20hit%20the%20APIM%20instance.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22devportal.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178414i1077E7DDA7813F88%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22devportal.jpg%22%20alt%3D%22devportal.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ECOMMON%20TROUBLESHOOTING%20SCENARIOS%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EWe%20would%20be%20covering%20some%20of%20the%20common%20Troubleshooting%20scenarios%20that%20might%20arise%20when%20we%20integrate%20an%20APIM%20service%20with%20an%20Application%20Gateway.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSTRONG%3EUnknown%20backend%20health%20%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EQuite%20often%2C%20we%20might%20have%20observed%20the%20backend%20health%20to%20be%20stuck%20in%20an%20Unknown%20state%20after%20completing%20the%20setup.%20The%20primary%20bottleneck%20could%20be%20the%20NSG%20associated%20with%20the%20subnet%20within%20which%20the%20App%20Gateway%20is%20setup.%3C%2FP%3E%0A%3CP%3EIf%20your%20requirement%20needs%20one%20of%20more%20NSGs%20to%20be%20in%20place%20then%2C%20you%20need%20to%20follow%20certain%20guidelines%20as%20documented%20below%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapplication-gateway%2Fconfiguration-overview%23network-security-groups-on-the-application-gateway-subnet%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapplication-gateway%2Fconfiguration-overview%23network-security-groups-on-the-application-gateway-subnet%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOther%20possible%20areas%20to%20check%20for%20Unknown%20backend%20health%20have%20been%20documented%20in%20another%20article%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapplication-gateway%2Fapplication-gateway-backend-health-troubleshooting%23backend-health-status-unknown%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapplication-gateway%2Fapplication-gateway-backend-health-troubleshooting%23backend-health-status-unknown%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%20start%3D%222%22%3E%0A%3CLI%3E%26nbsp%3B%3CSTRONG%3EIsolating%20the%20issue%20in%20the%20pipeline%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3ESince%20there%20are%20multiple%20components%20involved%20in%20this%20configuration%2C%20it%20is%20always%20a%20good%20practice%20to%20narrow%20down%20any%20issue%20faced%20to%20the%20specific%20component%20that%20is%20not%20working%20as%20expected.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EOne%20easy%20way%20of%20doing%20this%20would%20be%20using%20a%20Jump%20Box%20VM.%3C%2FLI%3E%0A%3CLI%3ECreate%20a%20sample%20Azure%20VM%20in%20the%20same%20VNet%20as%20that%20of%20the%20APIM.%3C%2FLI%3E%0A%3CLI%3EFor%20a%20quick%20test%2C%20we%20can%20update%20the%20VM%E2%80%99s%20host%20file%20with%20the%20private%20IP%20and%20the%20endpoints%20for%20the%20APIM%20Service.%3C%2FLI%3E%0A%3CLI%3EIf%20the%20APIM%20service%20is%20accessible%20from%20this%20VM%20which%20is%20a%20part%20of%20the%20same%20VNet%2C%20we%20would%20be%20able%20to%20narrow%20the%20issue%20down%20to%20App%20Gateway%20and%20DNS%20configuration.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EFREQUENTLY%20ASKED%20QUESTIONS%20(FAQs)%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EIs%20it%20mandatory%20to%20have%20NSGs%20in%20place%20running%20with%20the%20subnet%20of%20either%20the%20APIM%20or%20App%20Gateway%20in%20the%20setup%3F%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThis%20depends%20on%20your%20business%20requirement.%20If%20your%20organization%20needs%20to%20have%20NSG(s)%20enabled%2C%20you%20will%20need%20to%20whitelist%20the%20IP%20addresses%20as%20specified%20in%20the%20documentation%20above.%20There%20are%20no%20restrictions%20from%20Azure%20end%20while%20creating%20a%20setup%20without%20NSG.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3ECan%20we%20use%20standalone%20certificates%20in%20the%20deployment%3F%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ENo%2C%20since%20we%20would%20need%20the%20root%20certificate%20out%20of%20the%20chain%20(%20in%20.cer%20format%20)%20for%20the%20app%20gateway%20configuration.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3ECan%20the%20subnet%20hosting%20the%20APIM%20service%20be%20used%20for%20hosting%20other%20services%3F%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3ENo.%20The%20subnet%20within%20which%20the%20APIM%20service%20is%20deployed%20has%20to%20be%20a%20dedicated%20subnet.%20No%20other%20resource%20can%20share%20the%20same%20subnet.%20This%20is%20because%2C%20if%20the%20APIM%20service%20has%20to%20be%20scaled%20out%20in%20the%20future%2C%20the%20subnet%20should%20be%20able%20to%20have%20sufficient%20IP%20addresses%20reserved%20for%20the%20new%20instances%20of%20the%20APIM%20service.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EWhy%20are%20the%20links%20to%20my%20Developer%20Portal%20and%20the%20Publisher%20Portal%20of%20the%20APIM%20instance%20grayed%20out%20on%20the%20Azure%20Portal%3F%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3ESince%20you%20have%20deployed%20the%20APIM%20service%20within%20an%20Internal%20Virtual%20Network%2C%20it%20is%20no%20longer%20accessible%20over%20the%20public%20internet.%20You%20can%20successfully%20browse%20the%20same%20links%20from%20any%20local%20machine%20which%20has%20the%20Application%20Gateway%20Public%20IP%20mapped%20to%20the%20APIM%20custom%20domain%20names%20or%20has%20a%20custom%20DNS%20working%20as%20expected.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EHappy%20Learning!%20%3C%2FSTRONG%3E%3CSTRONG%3E%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Fhtml%2Fimages%2Femoticons%2Fsmile_40x40.gif%22%20alt%3D%22%3Asmile%3A%22%20title%3D%22%3Asmile%3A%22%20%2F%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1241650%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20API%20Management%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20App%20Gateway%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E

 

Integrating Application Gateway (v2) with API Management service in Internal Virtual network

 

Use Case

API Management service can be configured in Internal Virtual Network mode which makes it accessible only from within the Virtual Network. Using Application Gateway provides users the ability to protect the API Management service from OWASP vulnerabilities. Application gateway is a reverse proxy service which has a 7-layer load balancer and provides Web Application Firewall (WAF) as one of the services in this use case.

Internal Routing

In this configuration, all the calls that hit the APIM Service pass through the Application Gateway. A blocker here could be that Application Gateway routes the calls using IP address; However, APIM works on the basis of host names. Since there is only one private IP designated to all the endpoints of APIM service, we need to configure Application Gateway in such a manner that the respective host name is supplied to the APIM internal load balancer as per the call that needs to be routed to the designated endpoint (portal, management, proxy, et cetera)

Configuring the APIM

  1. Create an APIM Service following the steps explained in the below article : https://docs.microsoft.com/en-us/azure/api-management/get-started-create-service-instance
  2. Create a Virtual network under your Azure Subscription in the same location as that of APIM. Use this same VNet to deploy the APIM service in Internal VNet mode.
  3. Once configured, you would observe a Private IP for your APIM service on the Overview blade of the APIM Azure Portal. In this case, the private IP is 10.1.1.5

APIM in Private VnetAPIM in Private Vnet

  1. When the APIM service is in Internal VNet mode and the associated subnet has an NSG configured, there are certain network configurations that you need to add to the NSG associated to the subnet within which the APIM service resides.
  2. The following public documentation highlights these in detail and specifies all the ports that you would need to set in order to enable accessibility to the APIM service:

https://docs.microsoft.com/en-us/azure/api-management/api-management-using-with-vnet#-common-network...

 

Setting up Custom Domains

When you create an Azure APIM service, Azure assigns it a subdomain of azure-api.net (for example, apim-service-name.azure-api.net). However, you can also expose your APIM endpoints using your own custom domain name, such as xyz.com

 

  1. Under the Settings section, navigate to the Custom Domains blade on your API Management service.
  2. As you click the Add button, a new window would allow you to choose the type of endpoint along with the custom domain name you would like to configure.
  3. For this setup, I have used the management, proxy and portal endpoints of the APIM service to be invoked with the highlighted host name. Please be cautious to use new portal endpoint for configuration ( not legacy one)

    Setting up Custom DomainsSetting up Custom Domains

  4. As observed, when you add a custom domain with the preferred host name, you would need to furnish it with a valid .pfx certificate associated to the host name.
  5. The certificate to be used need to be different if you are using Application gateway version V1 or V2, this document explains in detail about the difference in certificates to be used : https://docs.microsoft.com/en-us/azure/application-gateway/certificates-for-backend-authentication#e...
  6. Wrapping it up as a  reference to above screenshot, Since I have been using hostnames for 3 different endpoints , V2 version would expect me to use 3 different certificates in .pfx format
  7. You can use any of the tools  like open ssl to create self-signed certificates. If you would like to do it using PowerShell, here is a sample script that can come handy :

 

# Create the root certificate for the self-signed certificate

$param1 = @{

  Subject = "CN=xyz, C=US"

  KeyLength = 2048

  KeyAlgorithm = 'RSA'

  HashAlgorithm = 'SHA256'

  KeyExportPolicy = 'Exportable'

  NotAfter = (Get-Date).AddYears(5)

  CertStoreLocation = 'Cert:\LocalMachine\My'

  KeyUsage = 'CertSign','CRLSign'

}

$rootCA = New-SelfSignedCertificate @param1

 

 

# Grab the thumbprint of the root certificate

$thumb = $rootCA.Thumbprint

$root = Get-Item -Path Cert:\LocalMachine\My\$($thumb)

#This is a path you want to download the .cer of the root certificate.

$path = "<add your local path here>"

 

 

# Export the root certificate in a Base64 encoded X.509 to the path created above

$base64certificate = @"

-----BEGIN CERTIFICATE-----

$([Convert]::ToBase64String($root.Export('Cert'), [System.Base64FormattingOptions]::InsertLineBreaks)))

-----END CERTIFICATE-----

"@

Set-Content -Path $path -Value $base64certificate

 

 

# Import the root certificate of the self-signed certificate to the local machine trusted root store

Import-Certificate -CertStoreLocation 'Cert:\CurrentUser\My' -FilePath "<update file path here>"

 

 

# Create a new self-signed certificate and then link the root and the self-signed certificate

$param2 = @{

    DnsName = '*.azure-apim.net'

    Subject = "management.azure-apim.net"

    Signer = $rootCA

    KeyLength = 2048

    KeyAlgorithm = 'RSA'

    HashAlgorithm = 'SHA256'

    KeyExportPolicy = 'Exportable'

    CertStoreLocation = 'Cert:\LocalMachine\My'

    NotAfter = (Get-date).AddYears(2)

}

$selfCert = New-SelfSignedCertificate @param2

 

 

# Export the certificate in .pfx format for the application gateway listener and ASE ILB Cert.

Export-PfxCertificate -Cert $selfCert -FilePath "<update file path>" -Password (ConvertTo-SecureString -AsPlainText '< choose password>' -Force)`

 

 

 

  1. As highlighted in the PowerShell script, you would have to make the changes as per your local environment.  A sample file path that you could provide would look something like this: “C:\Users\kwill\management.pfx”
  2. The subject part of the endpoint should change as per the endpoint you are using the certificate for. In this case, I have used the management endpoint since I would use this certificate for creating custom domain for my management endpoint.
  3. Run this script for all the endpoints that you wish to be mapped. This should yield you different certificates associated to the host names.
  4. Another thing worth mentioning is that if an APIM is configured to be in Internal VNet mode, it is expected to be running on its own custom DNS servers, and not Azure DNS.

Solving the issue for custom DNS

  • To mimic the custom DNS servers, we would be using the Azure Private DNS Zone offering.
  • Here are the steps that you could follow to create Private DNS zone: https://docs.microsoft.com/en-us/azure/dns/private-dns-getstarted-portal
  • The A records for the private DNS zones constitute the three endpoints of the APIM service pointing to the private IP of the service.

Configuring Private DNS zonesConfiguring Private DNS zones

 

  • One key point to remember is the Private DNS zone name should be a part of the FQDN for the host name.
  • In the above example. I have used the name as azure-apim.net , so that we can use all the endpoints as A records for the APIM Private IP.
  • Navigate to the Virtual Network Links blade of the private DNS Zone and link the Virtual Network. This would complete the setup for private DNS zones.

At this point of time, your APIM service has been configured to run inside a Virtual Network along with the custom domains.

Setting up App Gateway

  1. You can create the App Gateway using the steps explained in the below documentation:
  1. This article assumes that you have configured v2 version for the App Gateway as we move along with the setup ahead.
  2. As highlighted in the public documentation above, App Gateway has certain mandatory components that needs to be configured when we create it. We would be covering the details of the same below:

 

  • Backend Pool: App Gateway needs at least one backend pool to be configured during creation. Use the custom domain hostname of the API Management instance to be configured in the backend pool section.

 

Backend Pool ConfigurationBackend Pool Configuration

 

  • As a reference, we would be starting with the management endpoint configuration for now. You can repeat the same steps for Proxy or Portal endpoints.
  • We would be using three different backend pools for all the custom domains that we had configured earlier.
  • Use the custom domain hostname to be used as an FQDN in the backend pool. Let us call it managementbackend.

 

  • HttpSettings: These are the settings which include the protocols and probes configuration that the Application Gateway would be using to connect to the backend host names of APIM service.

 

Adding Http SettingsAdding Http Settings

 

  • To sync with the managementbackend(backend pool) highlighted in the previous step, we would go ahead and configure http settings called managementhttp

addhttp.jpg

 

  • Important point to note here is that the certificate to be added here has to be the root certificate (in .cer fomat) of the .pfx certificate that we created while creating the custom domains.
  • In a nutshell, I would use the management endpoint .pfx certificate and export it to .cer format. Later, we would need the root certificate of the exported certificate (in .cer format) to whitelist the management endpoint.
  • Kindly follow this documentation which contains a step-by-step demo for setting up certificates for v2 version Application Gateway:

https://docs.microsoft.com/en-us/azure/application-gateway/certificates-for-backend-authentication#e... . This step is crucial, and not having a valid root certificate may result in Internal Server Errors while deploying the Application Gateway.

  • As we scroll down, we need to select Yes for Override with new host name and Click on Pick host name from backend target (since hostname has already been specified in the backend pool)

 

addhttp1.jpg

 

  • This would associate the Http settings to the backend pool that we created for the management endpoint.
  • We would need to configure different Http settings for different backend pools that we create (in case we need to add proxy and portal endpoint).

 

  • Health Probes: These are the probes that would constantly keep checking the connection between the Application Gateway and the APIM service and would set the backend health value as per the configuration

 

updatedprobe.png

  • As observed, there would be multiple probes configured for multiple Http settings which would indicate the backend health for all the endpoints.
  • In case of proxy probe, /status 0123456789abcdef is a common health endpoint for the APIM service.

 

  • Listeners: We would be configuring different Listeners for different hostnames which are to be used in the Application Gateway

 

Listeners.jpg

 

  • Each of the listener would have a rule configured along with the hostname that we would associate it to.
  • Running through the managementlistener in this case, which has been setup to cater to the management hostname:

mgmtlistener.jpg

 

  • Please note that the certificate should be the same certificate in .pfx format that we had used earlier to create the management endpoint custom domain in APIM instance.
  • Since API management supports multiple endpoints, use a multi-site listener and add the associated hostname (which is the management hostname in this case)

 

  • Rules: We need to add routing rules that would be associated to the listeners and would have the configuration of the backend pool.

 

Rules.jpg

 

  • Add the backend targets with the backend pool and the Http settings that we had created earlier for the management endpoint.

 

  • Backend health: Backend health blade helps us verify whether the setup is working as expected. It would yield the results based on the probing checks of the health probes that we had previously configured for different end points.

 

backendhealth.jpg

 

  • A Healthy status in the backend health indicates that the App Gateway is able to talk to the API management service.

Validating the setup

  1. To ensure that the setup is working as expected, we can try to browse any of the configured endpoints from the local machine.
  2. Update the host file from this location (C:\Windows\System32\drivers\etc) on the local machine with the following additional entries as per the required configuration

hostfile.jpg

  • As observed, we need to map the public IP of the App Gateway to the hostname of the custom domains.
  • When you attempt to browse any of these endpoints from the local machine, you should be able to successfully hit the APIM instance.

devportal.jpg

 

COMMON TROUBLESHOOTING SCENARIOS:

We would be covering some of the common Troubleshooting scenarios that might arise when we integrate an APIM service with an Application Gateway.

  1. Unknown backend health

Quite often, we might have observed the backend health to be stuck in an Unknown state after completing the setup. The primary bottleneck could be the NSG associated with the subnet within which the App Gateway is setup.

If your requirement needs one of more NSGs to be in place then, you need to follow certain guidelines as documented below:

https://docs.microsoft.com/en-us/azure/application-gateway/configuration-overview#network-security-g...

 

Other possible areas to check for Unknown backend health have been documented in another article:

https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-backend-health-troubl...

 

  1.  Isolating the issue in the pipeline

Since there are multiple components involved in this configuration, it is always a good practice to narrow down any issue faced to the specific component that is not working as expected.

  • One easy way of doing this would be using a Jump Box VM.
  • Create a sample Azure VM in the same VNet as that of the APIM.
  • For a quick test, we can update the VM’s host file with the private IP and the endpoints for the APIM Service.
  • If the APIM service is accessible from this VM which is a part of the same VNet, we would be able to narrow the issue down to App Gateway and DNS configuration.

 

FREQUENTLY ASKED QUESTIONS (FAQs)

 

  • Is it mandatory to have NSGs in place running with the subnet of either the APIM or App Gateway in the setup?

This depends on your business requirement. If your organization needs to have NSG(s) enabled, you will need to whitelist the IP addresses as specified in the documentation above. There are no restrictions from Azure end while creating a setup without NSG.

  • Can we use standalone certificates in the deployment?

No, since we would need the root certificate out of the chain ( in .cer format ) for the app gateway configuration.

 

  • Can the subnet hosting the APIM service be used for hosting other services?

No. The subnet within which the APIM service is deployed has to be a dedicated subnet. No other resource can share the same subnet. This is because, if the APIM service has to be scaled out in the future, the subnet should be able to have sufficient IP addresses reserved for the new instances of the APIM service.

  • Why are the links to my Developer Portal and the Publisher Portal of the APIM instance grayed out on the Azure Portal?

Since you have deployed the APIM service within an Internal Virtual Network, it is no longer accessible over the public internet. You can successfully browse the same links from any local machine which has the Application Gateway Public IP mapped to the APIM custom domain names or has a custom DNS working as expected.

             

Happy Learning! :smile: