%3CLINGO-SUB%20id%3D%22lingo-sub-1737472%22%20slang%3D%22en-US%22%3EInteracting%20with%20Azure%20Stack%20Hub%20REST%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1737472%22%20slang%3D%22en-US%22%3E%3CP%3E%3CEM%3E%3CSPAN%3EIn%20this%20blog%20post%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2Fshriramnat%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EShriram%20Natarajan%3C%2FA%3E%26nbsp%3B(Senior%20Program%20Manager%2C%20Azure%20Stack%20Hub)%20walks%20us%20through%20how%20to%20interact%20with%20Azure%20Stack%20Hub%20using%20REST%20APIs.%26nbsp%3B%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CSPAN%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FEM%3E%3CEM%3E%3CSPAN%3EMicrosoft%20Azure%20cloud%20provides%20a%20robust%20platform%20for%20developers%20and%20operators%20to%20build%20and%20deploy%20their%20solutions%20seamlessly%20to%20the%20public%20cloud%2C%20the%20regional%20clouds%20as%20well%20as%20to%20Azure%20Stack%20Hub%20on-premises%20solutions.%20This%20ease%20of%20management%20is%20enabled%20by%20the%20consistent%20APIs%2C%20provided%20by%20the%20Cloud%20services%20available%20across%20all%20of%20these%20instances.%20Each%20cloud%20is%20fronted%20by%20the%20Azure%20Resource%20Manager%20(ARM)%20which%20simplifies%20the%20manage%20of%20application%20resources%2C%20enabling%20you%20to%20repeatedly%20deploy%20applications%2C%20with%20confidence%20that%20the%20resources%20are%20deployed%20in%20a%20consistent%20state.%20Azure%20Resource%20Manager%20makes%20it%20easy%20for%20you%20to%20manage%20and%20visualize%20resources%20in%20your%20app.%20You%20no%20longer%20have%20to%20deploy%20parts%20of%20your%20app%20separately%20and%20then%20manually%20stitch%20them%20together.%20You%20put%20resources%20with%20a%20common%20lifecycle%20into%20a%20resource%20group%20that%20can%20be%20deployed%20or%20deleted%20in%20a%20single%20action.%20You%20can%20see%20which%20resources%20are%20linked%20by%20a%20dependency.%20You%20can%20apply%20tags%20to%20resources%20to%20categorize%20them%20for%20management%20tasks%2C%20such%20as%20billing.%20On%20Azure%20Stack%20Hub%2C%20ARM%20is%20available%20for%20the%20cloud%20Operators%20as%20well%20to%20manage%20the%20cloud%20easily%20and%20ensure%20high%20availability%20to%20their%20customers.%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EAzure%20has%20robust%20tooling%20with%20SDKs%20in%20a%20variety%20of%20languages%20to%20help%20customers%20interact%20with%20the%20ARM%20APIs%20wherever%20they%20are.%20These%20tools%20are%20the%20recommended%20way%20to%20interact%20with%20any%20of%20the%20Azure%20clouds.%20However%2C%20there%20may%20be%20some%20cases%20where%20you%20would%20want%20to%20call%20the%20ARM%20APIs%20directly.%20For%20example%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSPAN%3EYou%20may%20need%20to%20call%20APIs%20that%20are%20not%20supported%20by%20tooling%20yet.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EThe%20tools%20standardize%20the%20parsing%20of%20the%20request%20responses%20to%20provide%20a%20good%20usability%20experience%20regardless%20of%20the%20service%20you%E2%80%99re%20calling.%20However%2C%20advanced%20users%20may%20require%20a%20different%20processing%20of%20this%20response%20based%20on%20their%20scenario.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EThe%20Azure%20SDKs%20are%20not%20available%20in%20the%20language%20of%20your%20choice%20and%20so%20you%20need%20to%20make%20direct%20REST%20calls%20to%20the%20ARM%20API.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%3EFor%20such%20scenarios%2C%20this%20blog%20will%20detail%20the%20process%20of%20making%20Authenticated%20API%20calls%20to%20the%20Azure%20Resource%20Manager.%20For%20the%20purposes%20of%20this%20blog%20we%20will%20use%20the%20ARM%20instance%20in%20Azure%20Stack%20Hub%2C%20but%20the%20process%20is%20the%20same%20regardless%20of%20whether%20you%20authenticate%20to%20Public%20Azure%2C%20any%20of%20the%20regional%20clouds%20or%20Azure%20Stack%20Edge.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThis%20blog%20will%20help%20you%20get%20boots%20on%20ground%20quick%20and%20get%20started%20with%20calling%20ARM.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%3ENote%3A%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSPAN%3EThis%20post%20focuses%20on%20Azure%20Stack%20Operators%20and%20the%20Admin%20ARM%20in%20Azure%20Stack%20Hub%2C%20but%20know%20that%20it%E2%80%99s%20the%20same%20process%20for%20the%20User%20ARM%20as%20well.%20%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EThis%20post%20will%20use%20%3CA%20href%3D%22https%3A%2F%2Fwww.postman.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPostman%3C%2FA%3E%20as%20a%20way%20to%20show%20the%20API%20calls.%20You%20can%20use%20the%20code%20generation%20part%20of%20the%20tool%20to%20generate%20the%20calls%20in%20a%20variety%20of%20languages.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CH1%20id%3D%22toc-hId-555958003%22%20id%3D%22toc-hId-555958031%22%3E%26nbsp%3B%3C%2FH1%3E%0A%3CH2%20id%3D%22toc-hId-1246519477%22%20id%3D%22toc-hId-1246519505%22%3E%3CSPAN%3EPre-Requisites%3A%3C%2FSPAN%3E%3C%2FH2%3E%0A%3COL%3E%0A%3CLI%3ECreate%20a%20%3CSTRONG%3EService%20Principal%3C%2FSTRONG%3E%20in%20%3CSTRONG%3EAzure%3C%2FSTRONG%3E%20and%20give%20it%20the%20right%20level%20of%20RBAC%20privileges%20on%20your%20%3CSTRONG%3EAzure%20Stack%20Hub%3C%2FSTRONG%3E%3CSPAN%3E%20installation.%20Following%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure-stack%2Foperator%2Fazure-stack-create-service-principals%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%20documentation%3C%2FA%3E%20will%20get%20you%20through%20it.%20%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CSTRONG%3E%3CSPAN%3ENote%3A%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%20this%20post%20will%20use%20Service%20Principal%20with%20a%20secret.%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%20start%3D%222%22%3E%0A%3CLI%3E%3CSPAN%3EDownload%20and%20install%20%3CA%20href%3D%22https%3A%2F%2Fwww.postman.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPostman%3C%2FA%3E.%20We%E2%80%99re%20going%20to%20assume%20some%20level%20of%20familiarity%20with%20Postman%20here%20to%20the%20extent%20of%20being%20able%20to%20modify%20values%20and%20being%20able%20to%20send%20requests.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--560934986%22%20id%3D%22toc-hId--560934958%22%3E%3CSPAN%3ESetting%20up%20the%20Requests%20and%20Environment%20Variables%20in%20Postman%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%3EDownload%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure-Samples%2FAzure-Stack-Hub-Foundation-Core%2Fblob%2Fmaster%2FTools%2FARMRequests-Postman%2FAzure%2520Stack%2520-%2520Admin%2520ARM%2520REST.postman_collection.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAPI%20requests%3C%2FA%3E%20and%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure-Samples%2FAzure-Stack-Hub-Foundation-Core%2Fblob%2Fmaster%2FTools%2FARMRequests-Postman%2FAzure%2520Stack%2520-%2520Admin%2520ARM%2520REST.postman_environment.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EEnvironment%20Variables%3C%2FA%3E.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EImport%20the%20API%20requests%20into%20postman%20using%20the%20import%20wizard.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22rctibi_0-1601596871711.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F223599i27A08C219B647E9F%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22rctibi_0-1601596871711.png%22%20alt%3D%22rctibi_0-1601596871711.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EClick%20on%20%3CSTRONG%3EUpload%3C%2FSTRONG%3E%20files%20and%20select%20both%20the%20%3CSTRONG%3E%3CEM%3EAzure%20Stack%20-%20Admin%20ARM%20REST.postman_collection.json%20%3C%2FEM%3E%3C%2FSTRONG%3Eand%3CSTRONG%3E%3CEM%3E%20Azure%20Stack%26nbsp%3B%20-%20Admin%20ARM%20REST.postman_environment.json%20%3C%2FEM%3E%3C%2FSTRONG%3Efiles.%20This%20will%20set%20up%20the%20necessary%20requests%20and%20the%20environment%20variables%20needed%20for%20you%20to%20follow%20along.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22rctibi_1-1601596871721.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F223600i105A94B3AE2CA07D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22rctibi_1-1601596871721.png%22%20alt%3D%22rctibi_1-1601596871721.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EMake%20sure%20you%20have%20the%20API%20request%20collection%20imported%20on%20the%20left%20nav.%20To%20see%20the%20Environment%20variables%2C%20click%20on%20the%20dropdown%20on%20the%20top%20right.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22rctibi_2-1601596871739.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F223601i628D6DA01CD95A18%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22rctibi_2-1601596871739.png%22%20alt%3D%22rctibi_2-1601596871739.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1926577847%22%20id%3D%22toc-hId-1926577875%22%3E%3CSPAN%3EConfigure%20your%20Environment%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%3EBefore%20you%20can%20start%20communicating%20with%20your%20Azure%20Stack%20Environment%2C%20you%20need%20to%20know%20a%20couple%20of%20things%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSTRONG%3E%3CSPAN%3EThe%20URL%20of%20the%20ARM%20endpoint%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%20for%20that%20Azure%20Stack%20.%20As%20an%20Azure%20Stack%20Operator%2C%20you%20interact%20with%20he%20Admin%20ARM%20which%20is%20typically%20at%20%3CA%20href%3D%22https%3A%2F%2Fadminmanagement.%7Bregion%7D.%7Bfqdn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fadminmanagement.%7Bregion%7D.%7Bfqdn%3C%2FA%3E%7D%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%3CSPAN%3EThe%20Azure%20Active%20Directory%20Tenant%20ID%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%20%E2%80%93%20the%20tenantID%20of%20the%20Directory%20that%20you%E2%80%99re%20going%20to%20log%20into%20using%20the%20Service%20Principal%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%3CSPAN%3EThe%20Service%20Principal%20credentials%20(App%20ID%20and%20Secret)%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%20that%20you%E2%80%99re%20going%20to%20use%20to%20authenticate%20to%20that%20ARM%20endpoint%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%3EYou%20can%20enter%20these%20values%20in%20the%20Environment%20setup%20in%20Postman.%20Click%20on%20the%20Manage%20Environments%20icon%20and%20Select%20the%20Azure%20Stack%20%E2%80%93%20Admin%20ARM%20REST%20environment.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22rctibi_3-1601596871741.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F223602i3DA8728AF58835A3%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22rctibi_3-1601596871741.png%22%20alt%3D%22rctibi_3-1601596871741.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22rctibi_4-1601596871746.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F223603iA6DCA9C3DFFD7587%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22rctibi_4-1601596871746.png%22%20alt%3D%22rctibi_4-1601596871746.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EReplace%20the%20%E2%80%9CCurrent%20Value%E2%80%9D%20field%20for%20all%20the%20variables%20with%20the%20values%20from%20your%20environment.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22rctibi_0-1601663890789.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F223706i4C7EB4A7A974F5A7%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22rctibi_0-1601663890789.png%22%20alt%3D%22rctibi_0-1601663890789.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-119123384%22%20id%3D%22toc-hId-119123412%22%3E%3CSPAN%3EThe%20Theory%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%3EBefore%20we%20start%20executing%20the%20postman%20requests%2C%20let%E2%80%99s%20quickly%20see%20an%20overview%20of%20the%20steps%20that%20need%20to%20be%20done%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSTRONG%3E%3CSPAN%3EDiscover%20the%20endpoints%20for%20the%20Azure%20Stack%20Hub%20%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%E2%80%93%20We%E2%80%99ll%20need%20a%20few%20endpoints%20other%20than%20ARM%20to%20interact%20with%20the%20cloud%20(e.g.%20the%20authentication%2Ftoken%20endpoint%20where%20you%20need%20to%20go%20to%20get%20a%20token%2C%20the%20audience%20to%20get%20the%20token%20for%20etc.).%20Fortunately%2C%20these%20are%20available%20to%20us%20through%20an%20unauthenticated%20API%20on%20ARM%20itself%2C%20so%20the%20first%20step%20is%20to%20call%20that%20API%20and%20get%20the%20values.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%3CSPAN%3EGet%20the%20AAD%20or%20AD%20FS%20Token%20endpoint%20by%20looking%20at%20the%20Open%20Id%20configuration%20%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%E2%80%93%20I%E2%80%99ll%20not%20get%20into%20details%20here%20about%20OpenID%2C%20Identity%20tokens%20and%20Access%20tokens%20etc.%20but%20know%20that%20the%20token%20endpoint%20is%20where%20you%20go%20and%20provide%20your%20credentials%20and%20get%20a%20token%20back%20after%20authentication.%20You%20will%20send%20this%20token%20to%20whichever%20application%20you%20are%20interacting%20with%20(ARM%20in%20this%20case)%20for%20it%20to%20authorize%20you%20and%20permit%20you%20to%20call%20it%E2%80%99s%20APIs%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%3CSPAN%3EAuthenticate%20with%20the%20identity%20system%20%E2%80%93%20%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3EAs%20mentioned%20above%2C%20you%20will%20need%20to%20send%20a%20request%20to%20the%20Token%20endpoint%20of%20the%20identity%20system%20and%20present%20your%20credentials%20(SP%20ID%20and%20secret)%2C%20and%20the%20target%20application%20(audience)%20you%E2%80%99re%20looking%20to%20interact%20with.%20If%20all%20the%20information%20you%20provided%20matches%2C%20the%20Identity%20System%20will%20now%20issue%20a%20token%20in%20response%20to%20this%20request.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%3CSPAN%3EMake%20an%20authenticated%20request%20to%20the%20necessary%20ARM%20API%20%E2%80%93%20%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3EYou%20can%20now%20call%20the%20ARM%20APIs%20by%20passing%20the%20token%20as%20a%20Bearer%20token%20in%20the%20header%20of%20the%20request.%20ARM%20will%20receive%20the%20token%20and%20verify%20if%20you%20have%20access%20to%20the%20API%20you%E2%80%99re%20calling%20and%20will%20respond%20with%20the%20right%20value%20as%20appropriate!%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%3ENow%20you%E2%80%99re%20ready%20to%20call%20the%20ARM%20endpoint%20and%20have%20authenticated%20interactions%20with%20the%20Cloud!%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%3ENote%3A%20%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3EMake%20sure%20the%20right%20Environment%20is%20selected%20in%20Postman%20before%20you%20execute%20the%20requests%20below.%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThis%20is%20one%20of%20the%20common%20causes%20for%20failure%20in%20following%20this%20guide.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22rctibi_6-1601596871759.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F223605i37C57E8712446678%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22rctibi_6-1601596871759.png%22%20alt%3D%22rctibi_6-1601596871759.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1688331079%22%20id%3D%22toc-hId--1688331051%22%3E%3CSPAN%3EExecute%20Endpoint%20Discovery%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%3EThis%20will%20send%20a%20request%20to%20%3C%2FSPAN%3E%3CSPAN%3E%7B%7BadminArmEndpoint%7D%7D%3C%2FSPAN%3E%2Fmetadata%2Fendpoints%3Fapi-version%3D2015-11-01%20%3CSPAN%3Ewith%20the%20adminArmEndpoint%20value%20being%20the%20one%20you%20set%20up%20in%20the%20Environment.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EYou%20will%20get%20the%20following%20response%20back%20from%20ARM.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22rctibi_3-1601665317249.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F223719i2B04D27CAAE7A3EA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22rctibi_3-1601665317249.png%22%20alt%3D%22rctibi_3-1601665317249.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EUsing%20the%20%E2%80%9CTests%E2%80%9D%20functionality%20in%20POSTMAN%2C%20we%E2%80%99re%20creating%20additional%20environment%20variables%20using%20the%20values%20in%20the%20response.%20The%20most%20important%20ones%20are%20the%20ARM%20Audience%20and%20the%20loginEndpoint.%20These%20variables%20will%20be%20used%20for%20subsequent%20requests.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22rctibi_1-1601665186265.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F223717iABC78BC946354141%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22rctibi_1-1601665186265.png%22%20alt%3D%22rctibi_1-1601665186265.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-799181754%22%20id%3D%22toc-hId-799181782%22%3E%3CSPAN%3EExecute%20AAD%20Token%20Endpoint%20Discovery%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%3EThis%20step%20will%20send%20a%20call%20to%20the%20AAD%20or%20AD%20FS%20endpoint%20discovered%20in%20the%20previous%20step%20to%20fetch%20the%20actual%20token%20endpoint%20where%20we%20will%20need%20to%20send%20our%20credentials.%20The%20token%20endpoint%20can%20be%20read%20from%20the%20%E2%80%9COpen%20ID%20connect%20Configuration%E2%80%9D%20for%20that%20Identity%20system.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22rctibi_5-1601665411049.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F223721i6ACB00B28F572550%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22rctibi_5-1601665411049.png%22%20alt%3D%22rctibi_5-1601665411049.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EWe%20will%20again%20use%20the%20Tests%20to%20save%20this%20into%20a%20new%20environment%20variable.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1008272709%22%20id%3D%22toc-hId--1008272681%22%3E%3CSPAN%3EAuthenticating%20with%20the%20Identity%20System%20and%20getting%20a%20token%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3EExecute%20the%20Authenticate%20Service%20Principal%20request%20next%20and%20make%20sure%20that%20the%20service%20Principal%20ID%20and%20secret%20are%20set%20in%20the%20environment.%20This%20will%20send%20a%20request%20to%20the%20token%20endpoint%20discovered%20in%20the%20previous%20step%20along%20with%20the%20credentials%20and%20the%20ARM%20audience%20inferred%20from%20the%20endpoint%20discovery%20step.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22rctibi_0-1601665604106.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F223723i7C0A85AFC4174F15%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22rctibi_0-1601665604106.png%22%20alt%3D%22rctibi_0-1601665604106.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EAssuming%20your%20credentials%20are%20correct%20and%20you%20do%20have%20the%20permission%20to%20request%20a%20token%2C%20you%20will%20get%20the%20access%20token%20back%20in%20the%20response%20as%20seen%20above.%20Using%20Tests%2C%20we%20will%20store%20this%20token%20in%20a%20new%20variable%20inside%20the%20environment.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAt%20this%20point%20you%20have%20everything%20you%20need%20to%20interact%20with%20ARM!%20The%20first%20thing%20you%20would%20need%20to%20know%20is%20the%20subscription%20ID%20%E2%80%93%20in%20this%20scenario%2C%20the%20operator%20would%20need%20to%20know%20the%20id%20of%20the%20Default%20Provider%20Subscription.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1479240124%22%20id%3D%22toc-hId-1479240152%22%3E%3CSPAN%3EExecute%20Get%20Default%20Provider%20Subscription%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%3EThis%20will%20send%20a%20request%20to%20the%20%3C%2FSPAN%3E%3CSPAN%3E%7B%7BadminArmEndpoint%7D%7D%3C%2FSPAN%3E%2Fsubscriptions%3Fapi-version%3D2015-01-06%20%3CSPAN%3Eendpoint.%20Note%20that%20the%20token%20is%20sent%20as%20a%20Bearer%20token%20in%20the%20Authorization%20Header%20of%20the%20request.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSTRONG%3ENote%3A%3C%2FSTRONG%3E%20the%20number%20of%20subscriptions%20returned%20in%20this%20request%20is%20dependent%20on%20the%20number%20of%20subscriptions%20the%20Service%20Principal%20has%20access%20to%20on%20the%20Admin%20ARM.%20In%20this%20case%2C%20the%20Service%20Principal%20has%20access%20only%20to%20the%20Default%20Provider%20Subscription%2C%20and%20so%20only%20one%20will%20be%20returned.%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22rctibi_0-1601665792398.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F223725iACAE2A707C435359%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22rctibi_0-1601665792398.png%22%20alt%3D%22rctibi_0-1601665792398.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorrctibi_15%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--328214339%22%20id%3D%22toc-hId--328214311%22%3E%3CSPAN%3EExecute%20Get%20Location%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%3EFollowing%20the%20same%20template%20for%20get%20subscription%2C%20we%20can%20also%20get%20the%20default%20location%20for%20that%20Azure%20Stack%20Stamp.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorrctibi_16%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22rctibi_1-1601665853679.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F223726iB536EA9968AE16DE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22rctibi_1-1601665853679.png%22%20alt%3D%22rctibi_1-1601665853679.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--461899063%22%20id%3D%22toc-hId--461899035%22%3E%3CSPAN%3EExecute%20Get%20namespaces%20within%20a%20subscription%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%3EExecuting%20this%20will%20send%20a%20request%20to%20the%20%2Fproviders%20API%20which%20will%20return%20all%20the%20namespaces%20and%20the%20corresponding%20resource%20types%20and%20api-versions%20available%20under%20them.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorrctibi_17%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22rctibi_2-1601665914650.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F223727i09011F1EA18E86A8%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22rctibi_2-1601665914650.png%22%20alt%3D%22rctibi_2-1601665914650.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EWith%20the%20information%20we%E2%80%99ve%20obtained%20from%20the%20above%20requests%20viz.%20Arm%20Endpoint%2C%20subscriptionID%2C%20location%2C%20namespaces%2C%20resource%20types%20and%20API%20versions%20that%20are%20available%20to%20the%20subscription%2C%20we%20can%20compose%20other%20requests%20to%20ARM.%20The%20Postman%20Request%20collection%20has%20samples%20of%20other%20such%20API%20calls%20you%20can%20compose%20with%20this%20information.%20Feel%20free%20to%20give%20them%20a%20whirl!%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-2025613770%22%20id%3D%22toc-hId-2025613798%22%3E%3CSPAN%3EResources%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%3EHere%20are%20some%20resources%20that%20do%20a%20great%20job%20in%20providing%20you%20an%20overview%20of%20ARM%20and%20how%20to%20interact%20with%20it.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-resource-manager%2Fmanagement%2Foverview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EThis%20article%3C%2FA%3E%26nbsp%3Bprovides%20a%20great%20overview%20of%20ARM%20and%20its%20placement%20in%20the%20overall%20Azure%20Architecture.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EThis%20is%20a%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure-stack%2Fuser%2Fazure-stack-rest-api-use%3Fview%3Dazs-2005%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Egood%20doc%3C%2FA%3E%26nbsp%3Bwith%20details%20on%20authenticating%20and%20calling%20Azure%20Resource%20Manager%20on%20Azure%20Stack%20Hub.%20It%20provides%20a%20detailed%20description%20of%20how%20to%20interact%20with%20Azure%20Stack%20Hub%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EAs%20always%2C%20check%20out%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Frest%2Fapi%2Fazure%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20API%20reference%3C%2FA%3E.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3BFor%20learning%20more%20about%20operating%20an%20Azure%20Stack%20Hub%2C%20check%20the%26nbsp%3B%3C%2FSPAN%3E%3CA%20style%3D%22background-color%3A%20%23ffffff%3B%22%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure-Samples%2FAzure-Stack-Hub-Foundation-Core%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FAzure-Samples%2FAzure-Stack-Hub-Foundation-Core%3C%2FA%3E%26nbsp%3Bwhich%20includes%20videos%2C%20slides%2C%20and%20workshops.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1737472%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20API%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20Stack%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20Stack%20Hub%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

In this blog post, Shriram Natarajan (Senior Program Manager, Azure Stack Hub) walks us through how to interact with Azure Stack Hub using REST APIs. 


Microsoft Azure cloud provides a robust platform for developers and operators to build and deploy their solutions seamlessly to the public cloud, the regional clouds as well as to Azure Stack Hub on-premises solutions. This ease of management is enabled by the consistent APIs, provided by the Cloud services available across all of these instances. Each cloud is fronted by the Azure Resource Manager (ARM) which simplifies the manage of application resources, enabling you to repeatedly deploy applications, with confidence that the resources are deployed in a consistent state. Azure Resource Manager makes it easy for you to manage and visualize resources in your app. You no longer have to deploy parts of your app separately and then manually stitch them together. You put resources with a common lifecycle into a resource group that can be deployed or deleted in a single action. You can see which resources are linked by a dependency. You can apply tags to resources to categorize them for management tasks, such as billing. On Azure Stack Hub, ARM is available for the cloud Operators as well to manage the cloud easily and ensure high availability to their customers.

 

Azure has robust tooling with SDKs in a variety of languages to help customers interact with the ARM APIs wherever they are. These tools are the recommended way to interact with any of the Azure clouds. However, there may be some cases where you would want to call the ARM APIs directly. For example:

  1. You may need to call APIs that are not supported by tooling yet.
  2. The tools standardize the parsing of the request responses to provide a good usability experience regardless of the service you’re calling. However, advanced users may require a different processing of this response based on their scenario.
  3. The Azure SDKs are not available in the language of your choice and so you need to make direct REST calls to the ARM API.

For such scenarios, this blog will detail the process of making Authenticated API calls to the Azure Resource Manager. For the purposes of this blog we will use the ARM instance in Azure Stack Hub, but the process is the same regardless of whether you authenticate to Public Azure, any of the regional clouds or Azure Stack Edge.

 

This blog will help you get boots on ground quick and get started with calling ARM.

 

Note:

  1. This post focuses on Azure Stack Operators and the Admin ARM in Azure Stack Hub, but know that it’s the same process for the User ARM as well.
  2. This post will use Postman as a way to show the API calls. You can use the code generation part of the tool to generate the calls in a variety of languages.

 

Pre-Requisites:

  1. Create a Service Principal in Azure and give it the right level of RBAC privileges on your Azure Stack Hub installation. Following this documentation will get you through it.

Note: this post will use Service Principal with a secret.

  1. Download and install Postman. We’re going to assume some level of familiarity with Postman here to the extent of being able to modify values and being able to send requests.

 

Setting up the Requests and Environment Variables in Postman

Download the API requests and Environment Variables.

 

Import the API requests into postman using the import wizard.

rctibi_0-1601596871711.png

 

Click on Upload files and select both the Azure Stack - Admin ARM REST.postman_collection.json and Azure Stack  - Admin ARM REST.postman_environment.json files. This will set up the necessary requests and the environment variables needed for you to follow along.

rctibi_1-1601596871721.png

 

Make sure you have the API request collection imported on the left nav. To see the Environment variables, click on the dropdown on the top right.

rctibi_2-1601596871739.png

 

Configure your Environment

Before you can start communicating with your Azure Stack Environment, you need to know a couple of things:

  1. The URL of the ARM endpoint for that Azure Stack . As an Azure Stack Operator, you interact with he Admin ARM which is typically at https://adminmanagement.{region}.{fqdn}
  2. The Azure Active Directory Tenant ID – the tenantID of the Directory that you’re going to log into using the Service Principal
  3. The Service Principal credentials (App ID and Secret) that you’re going to use to authenticate to that ARM endpoint

You can enter these values in the Environment setup in Postman. Click on the Manage Environments icon and Select the Azure Stack – Admin ARM REST environment.

rctibi_3-1601596871741.png

 

rctibi_4-1601596871746.png

Replace the “Current Value” field for all the variables with the values from your environment.

rctibi_0-1601663890789.png

 

 

The Theory

Before we start executing the postman requests, let’s quickly see an overview of the steps that need to be done:

  1. Discover the endpoints for the Azure Stack Hub – We’ll need a few endpoints other than ARM to interact with the cloud (e.g. the authentication/token endpoint where you need to go to get a token, the audience to get the token for etc.). Fortunately, these are available to us through an unauthenticated API on ARM itself, so the first step is to call that API and get the values.
  2. Get the AAD or AD FS Token endpoint by looking at the Open Id configuration – I’ll not get into details here about OpenID, Identity tokens and Access tokens etc. but know that the token endpoint is where you go and provide your credentials and get a token back after authentication. You will send this token to whichever application you are interacting with (ARM in this case) for it to authorize you and permit you to call it’s APIs
  3. Authenticate with the identity system – As mentioned above, you will need to send a request to the Token endpoint of the identity system and present your credentials (SP ID and secret), and the target application (audience) you’re looking to interact with. If all the information you provided matches, the Identity System will now issue a token in response to this request.
  4. Make an authenticated request to the necessary ARM API – You can now call the ARM APIs by passing the token as a Bearer token in the header of the request. ARM will receive the token and verify if you have access to the API you’re calling and will respond with the right value as appropriate!

Now you’re ready to call the ARM endpoint and have authenticated interactions with the Cloud!

 

Note: Make sure the right Environment is selected in Postman before you execute the requests below.

This is one of the common causes for failure in following this guide.

rctibi_6-1601596871759.png

 

Execute Endpoint Discovery

This will send a request to {{adminArmEndpoint}}/metadata/endpoints?api-version=2015-11-01 with the adminArmEndpoint value being the one you set up in the Environment.

 

You will get the following response back from ARM.

rctibi_3-1601665317249.png

 

 

Using the “Tests” functionality in POSTMAN, we’re creating additional environment variables using the values in the response. The most important ones are the ARM Audience and the loginEndpoint. These variables will be used for subsequent requests.

rctibi_1-1601665186265.png

 

Execute AAD Token Endpoint Discovery

This step will send a call to the AAD or AD FS endpoint discovered in the previous step to fetch the actual token endpoint where we will need to send our credentials. The token endpoint can be read from the “Open ID connect Configuration” for that Identity system.

rctibi_5-1601665411049.png

 

We will again use the Tests to save this into a new environment variable.

 

Authenticating with the Identity System and getting a token

Execute the Authenticate Service Principal request next and make sure that the service Principal ID and secret are set in the environment. This will send a request to the token endpoint discovered in the previous step along with the credentials and the ARM audience inferred from the endpoint discovery step.

 

rctibi_0-1601665604106.png

 

Assuming your credentials are correct and you do have the permission to request a token, you will get the access token back in the response as seen above. Using Tests, we will store this token in a new variable inside the environment.

 

At this point you have everything you need to interact with ARM! The first thing you would need to know is the subscription ID – in this scenario, the operator would need to know the id of the Default Provider Subscription.

 

Execute Get Default Provider Subscription

This will send a request to the {{adminArmEndpoint}}/subscriptions?api-version=2015-01-06 endpoint. Note that the token is sent as a Bearer token in the Authorization Header of the request.

 

Note: the number of subscriptions returned in this request is dependent on the number of subscriptions the Service Principal has access to on the Admin ARM. In this case, the Service Principal has access only to the Default Provider Subscription, and so only one will be returned.

 

rctibi_0-1601665792398.png

 

 

 

Execute Get Location

Following the same template for get subscription, we can also get the default location for that Azure Stack Stamp.

 

rctibi_1-1601665853679.png

 

Execute Get namespaces within a subscription

Executing this will send a request to the /providers API which will return all the namespaces and the corresponding resource types and api-versions available under them.

 

rctibi_2-1601665914650.png

 

 

With the information we’ve obtained from the above requests viz. Arm Endpoint, subscriptionID, location, namespaces, resource types and API versions that are available to the subscription, we can compose other requests to ARM. The Postman Request collection has samples of other such API calls you can compose with this information. Feel free to give them a whirl!

 

Resources

Here are some resources that do a great job in providing you an overview of ARM and how to interact with it.

  • This article provides a great overview of ARM and its placement in the overall Azure Architecture.
  • This is a good doc with details on authenticating and calling Azure Resource Manager on Azure Stack Hub. It provides a detailed description of how to interact with Azure Stack Hub
  • As always, check out the Azure API reference.

 For learning more about operating an Azure Stack Hub, check the https://github.com/Azure-Samples/Azure-Stack-Hub-Foundation-Core which includes videos, slides, and workshops.