Skip to content
Merged
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions src/main/java/com/datadog/ServerlessCompatAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public static String getPackageVersion() {
return packageVersion == null ? "unknown" : packageVersion;
}

public static boolean isAzureFlexWithoutDDAzureResourceGroup() {
return "FlexConsumption".equals(System.getenv("WEBSITE_SKU")) && System.getenv("DD_AZURE_RESOURCE_GROUP") == null;
}

public static void premain(String agentArgs, Instrumentation instrumentation) {
CloudEnvironment environment = getEnvironment();
log.debug("Environment detected: {}", environment);
Expand All @@ -90,6 +94,12 @@ public static void premain(String agentArgs, Instrumentation instrumentation) {
return;
}

// Check for Azure Flex Consumption functions that don't have the DD_AZURE_RESOURCE_GROUP environment variable set
if (environment == CloudEnvironment.AZURE_FUNCTION && isAzureFlexWithoutDDAzureResourceGroup()) {
log.error("Azure function detected on flex consumption plan without DD_AZURE_RESOURCE_GROUP set. Please set the DD_AZURE_RESOURCE_GROUP environment variable to your resource group name in Azure app settings. Shutting down Datadog Serverless Compatibility Layer.");
return;
}

try (InputStream inputStream = ServerlessCompatAgent.class.getClassLoader()
.getResourceAsStream(fileName)) {
if (inputStream == null) {
Expand Down