User Tools

Site Tools


wiki:connect_azure_rest_api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
wiki:connect_azure_rest_api [2022/08/30 13:45] – created antisawiki:connect_azure_rest_api [2023/09/05 11:29] (current) – Add Renew/generate new token i.e. client secret antisa
Line 2: Line 2:
  
 ====== Connect to Azure REST API ====== ====== Connect to Azure REST API ======
 +This uses so-called [[https://docs.microsoft.com/en-us/rest/api/azure/#client-credentials-grant-non-interactive-clients|client credentials grant]] for accessing the API. There are also [[https://docs.microsoft.com/en-us/rest/api/azure/#authorization-code-grant-interactive-clients|authorization via code]] to get the token mentioned below.
 +
  
 In your account open the azure shell. After connecting create the principal In your account open the azure shell. After connecting create the principal
Line 19: Line 21:
  
 This data can now be used to get query the API but you still need the **BearerToken** which can be obtained via [[https://docs.microsoft.com/en-us/rest/api/sql/2021-02-01-preview/firewall-rules/list-by-server?tabs=HTTP|this script]], which can be used in Postman as a //"Pre-request Script"// This data can now be used to get query the API but you still need the **BearerToken** which can be obtained via [[https://docs.microsoft.com/en-us/rest/api/sql/2021-02-01-preview/firewall-rules/list-by-server?tabs=HTTP|this script]], which can be used in Postman as a //"Pre-request Script"//
 +
 +You can also get the token via curl see [[https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow#get-a-token|this]]
 +
 +====== Renew/generate new token i.e. client secret ======
 +
 +  -  In the Azure portal, in App registrations, select your application.
 +  - Select Certificates & secrets > Client secrets > New client secret.
 +  - Add a description for your client secret.
 +  - Select an expiration for the secret or specify a custom lifetime. Client secret lifetime is limited to two years (24 months) or less. You can't specify a custom lifetime longer than 24 months. Microsoft recommends that you set an expiration value of less than 12 months.
 +  - Select Add.
 +  - Record the secret's value for use in your client application code. This secret value is never displayed again after you leave this page.
 +
 +
 ====== Tested on ====== ====== Tested on ======
   * Microsoft Azure accessed on 2022-08-30   * Microsoft Azure accessed on 2022-08-30
  
 ====== See also ====== ====== See also ======
 +  * [[wiki:updateing_azure_database_firewall_via_api|Updateing Azure database firewall via Azure API]]
 ====== References ====== ====== References ======
   * https://blog.jongallant.com/2021/02/azure-rest-apis-postman-2021/   * https://blog.jongallant.com/2021/02/azure-rest-apis-postman-2021/
   * https://docs.microsoft.com/en-us/rest/api/azure/   * https://docs.microsoft.com/en-us/rest/api/azure/
 +  * https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow#get-a-token
  
  
wiki/connect_azure_rest_api.1661859916.txt.gz · Last modified: 2022/08/30 13:45 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki