When your container is hosted in a Consumption + Dedicated plan structure, + * only the default Consumption plan is currently supported. Dedicated plans in this structure aren't yet supported for Functions. + * When running functions on Container Apps, you're charged only for the Container Apps usage.
+ * + * @param managedEnvironmentId ID of the Azure Container Apps environment + * @return the next stage of the definition + */ + WithScaleRulesOrDockerContainerImage withManagedEnvironmentId(String managedEnvironmentId); + } + + /** A function app definition allowing scale rules to be specified for Function Apps hosted on Azure Container Apps. */ + interface WithScaleRulesOrDockerContainerImage extends WithDockerContainerImage { + /** + * Specifies the maximum replica count. + * + * @param maxReplicas maximum replica count + * @return the next stage of the definition + */ + WithScaleRulesOrDockerContainerImage withMaxReplicas(int maxReplicas); + + /** + * Specifies the minimum replica count. + * + * @param minReplicas minimum replica count + * @return the next stage of the definition + */ + WithScaleRulesOrDockerContainerImage withMinReplicas(int minReplicas); + } + /** A function app definition allowing docker registry credentials to be set. */ interface WithCredentials { /** @@ -728,6 +787,25 @@ interface WithCredentials { */ Update withCredentials(String username, String password); } + + /** A function app update allowing scale rules to be set if hosted on Azure Container Apps environment. */ + interface WithManagedEnvironmentScaleRules { + /** + * Specifies the maximum replica count. + * + * @param maxReplicas maximum replica count + * @return the next stage of the function app update + */ + Update withMaxReplicas(int maxReplicas); + + /** + * Specifies the minimum replica count. + * + * @param minReplicas minimum replica count + * @return the next stage of the definition + */ + Update withMinReplicas(int minReplicas); + } } /** The template for a function app update operation, containing all the settings that can be modified. */ @@ -738,6 +816,7 @@ interface Update UpdateStages.WithStorageAccount, UpdateStages.WithDailyUsageQuota, UpdateStages.WithDockerContainerImage, - UpdateStages.WithCredentials { + UpdateStages.WithCredentials, + UpdateStages.WithManagedEnvironmentScaleRules { } } diff --git a/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/AppServiceTest.java b/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/AppServiceTest.java index 85e0e9903c987..a8c1600cbc62c 100644 --- a/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/AppServiceTest.java +++ b/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/AppServiceTest.java @@ -47,7 +47,7 @@ /** The base for app service tests. */ public class AppServiceTest extends ResourceManagerTestProxyTestBase { - private static final ClientLogger LOGGER = new ClientLogger(AppServiceTest.class); + static final ClientLogger LOGGER = new ClientLogger(AppServiceTest.class); protected ResourceManager resourceManager; protected KeyVaultManager keyVaultManager; diff --git a/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/FunctionAppsTests.java b/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/FunctionAppsTests.java index 31bfbda04e469..020ba5b014376 100644 --- a/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/FunctionAppsTests.java +++ b/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/FunctionAppsTests.java @@ -6,7 +6,11 @@ import com.azure.core.http.HttpPipeline; import com.azure.core.http.rest.PagedIterable; import com.azure.core.http.rest.Response; +import com.azure.core.management.Region; import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.profile.AzureProfile; +import com.azure.resourcemanager.appcontainers.ContainerAppsApiManager; +import com.azure.resourcemanager.appcontainers.models.ManagedEnvironment; import com.azure.resourcemanager.appservice.models.AppServicePlan; import com.azure.resourcemanager.appservice.models.AppSetting; import com.azure.resourcemanager.appservice.models.FunctionApp; @@ -16,23 +20,24 @@ import com.azure.resourcemanager.appservice.models.FunctionRuntimeStack; import com.azure.resourcemanager.appservice.models.PricingTier; import com.azure.resourcemanager.appservice.models.SkuName; -import com.azure.resourcemanager.test.utils.TestUtilities; -import com.azure.core.management.Region; -import com.azure.core.management.profile.AzureProfile; import com.azure.resourcemanager.resources.fluentcore.utils.ResourceManagerUtils; +import com.azure.resourcemanager.resources.models.ResourceGroup; +import com.azure.resourcemanager.storage.StorageManager; import com.azure.resourcemanager.storage.models.StorageAccount; import com.azure.resourcemanager.storage.models.StorageAccountSkuType; -import com.azure.resourcemanager.storage.StorageManager; +import com.azure.resourcemanager.test.utils.TestDelayProvider; +import com.azure.resourcemanager.test.utils.TestUtilities; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + import java.io.File; +import java.lang.reflect.Constructor; import java.time.Duration; import java.util.Arrays; import java.util.Map; import java.util.regex.Pattern; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - public class FunctionAppsTests extends AppServiceTest { private String rgName1 = ""; private String rgName2 = ""; @@ -44,6 +49,7 @@ public class FunctionAppsTests extends AppServiceTest { private String storageAccountName1 = ""; protected StorageManager storageManager; + protected ContainerAppsApiManager containerAppsApiManager; @Override protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) { @@ -57,6 +63,21 @@ protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile rgName2 = generateRandomResourceName("javacsmrg", 20); storageManager = buildManager(StorageManager.class, httpPipeline, profile); + // build ContainerAppsApiManager + try { + Constructor