Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to latest Azure SDK API #1418

Merged
merged 33 commits into from
Sep 30, 2020
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c97b863
Fix AEv2 tests exclude for reqExternalSetup and cleanup (#1247)
lilgreenbird Feb 5, 2020
54b5a19
Fix | Add null check for getObject() with LocalTime and LocalDate (#1…
peterbae Feb 8, 2020
672b7d6
added all AKV tests to use reqExternalSetup tag so they will be skipp…
lilgreenbird Feb 10, 2020
3c3331b
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Mar 25, 2020
e2c5640
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Mar 26, 2020
aad6966
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Mar 28, 2020
92bf04c
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Mar 31, 2020
3ba5ab7
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Apr 4, 2020
d20823d
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Apr 7, 2020
4cc959f
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Apr 29, 2020
7b301f8
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Apr 30, 2020
56bcf13
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird May 7, 2020
744e0ca
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird May 12, 2020
df8fd41
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird May 19, 2020
652e68b
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird May 26, 2020
53736db
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird May 26, 2020
9ba6a42
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Jun 2, 2020
6d156f7
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Jun 5, 2020
e08ffe5
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Jun 10, 2020
6b6cab2
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Jun 18, 2020
c202590
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Jun 24, 2020
0515d4b
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Jun 24, 2020
2c63b58
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Jun 25, 2020
78aa941
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Jul 2, 2020
90e99cd
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Jul 2, 2020
da1004b
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Jul 6, 2020
9ca1284
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Jul 28, 2020
c67d8ed
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Aug 1, 2020
1d0a4ad
Merge remote-tracking branch 'upstream/dev' into dev
lilgreenbird Aug 5, 2020
4810414
Merge remote-tracking branch 'upstream/dev' into msiauth
lilgreenbird Aug 27, 2020
b96f5fa
added IDENTITY_ENDPOINT and IDENTITY_HEADER
lilgreenbird Aug 28, 2020
f95a3b8
Merge remote-tracking branch 'upstream/dev' into msiauth
lilgreenbird Sep 10, 2020
159df4e
review update
lilgreenbird Sep 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -253,25 +253,34 @@ static SqlFedAuthToken getMSIAuthToken(String resource, String msiClientId) thro
// IMDS upgrade time can take up to 70s
final int imdsUpgradeTimeInMs = 70 * 1000;
final List<Integer> retrySlots = new ArrayList<>();
final String msiEndpoint = System.getenv("MSI_ENDPOINT");
final String msiSecret = System.getenv("MSI_SECRET");

StringBuilder urlString = new StringBuilder();
int retry = 1, maxRetry = 1;

// MSI_ENDPOINT and MSI_SECRET can be used instead of IDENTITY_ENDPOINT and IDENTITY_HEADER
String identityEndpoint = System.getenv("IDENTITY_ENDPOINT");
if (null == identityEndpoint || identityEndpoint.trim().isEmpty()) {
identityEndpoint = System.getenv("MSI_ENDPOINT");
}

String identityHeader = System.getenv("IDENTITY_HEADER");
if (null == identityHeader || identityHeader.trim().isEmpty()) {
identityHeader = System.getenv("MSI_SECRET");
}

/*
* isAzureFunction is used for identifying if the current client application is running in a Virtual Machine
* (without MSI environment variables) or App Service/Function (with MSI environment variables) as the APIs to
* be called for acquiring MSI Token are different for both cases.
* (without Managed Identity environment variables) or App Service/Function (with Managed Identity environment
* variables) as the APIs to be called for acquiring MSI Token are different for both cases.
*/
boolean isAzureFunction = null != msiEndpoint && !msiEndpoint.isEmpty() && null != msiSecret
&& !msiSecret.isEmpty();
boolean isAzureFunction = null != identityEndpoint && !identityEndpoint.isEmpty() && null != identityHeader
&& !identityHeader.isEmpty();

if (isAzureFunction) {
urlString.append(msiEndpoint).append("?api-version=2019-08-01&resource=").append(resource);
urlString.append(identityEndpoint).append("?api-version=2019-08-01&resource=").append(resource);
} else {
urlString.append(ActiveDirectoryAuthentication.AZURE_REST_MSI_URL).append("&resource=").append(resource);
// Retry acquiring access token upto 20 times due to possible IMDS upgrade (Applies to VM only)
// Retry acquiring access token up to 20 times due to possible IMDS upgrade (Applies to VM only)
maxRetry = 20;
// Simplified variant of Exponential BackOff
for (int x = 0; x < maxRetry; x++) {
Expand All @@ -293,14 +302,14 @@ static SqlFedAuthToken getMSIAuthToken(String resource, String msiClientId) thro
connection.setRequestMethod("GET");

if (isAzureFunction) {
connection.setRequestProperty("X-IDENTITY-HEADER", msiSecret);
connection.setRequestProperty("X-IDENTITY-HEADER", identityHeader);
if (connectionlogger.isLoggable(Level.FINER)) {
connectionlogger.finer("Using Azure Function/App Service MSI auth: " + urlString);
connectionlogger.finer("Using Azure Function/App Service Managed Identity auth: " + urlString);
}
} else {
connection.setRequestProperty("Metadata", "true");
if (connectionlogger.isLoggable(Level.FINER)) {
connectionlogger.finer("Using Azure MSI auth: " + urlString);
connectionlogger.finer("Using Azure Managed Identity auth: " + urlString);
}
}

Expand Down