Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.33k stars 1.97k forks source link

[FEATURE REQ] mgmt function app, convenience API for creating function app with `managedEnvironmentId` #37156

Closed XiaofeiCao closed 9 months ago

XiaofeiCao commented 11 months ago

docs: https://learn.microsoft.com/en-us/azure/azure-functions/functions-container-apps-hosting

It's a new hosting plan compared to previous App Service Plans: All hosting plans

Some major implementation differences(found in azure-cli, may not be exhaustive): For managed container app environment based(Centauri) Function Apps

  1. SiteConfig needs to be set to SiteInner.siteConfig when creating FunctionApp, instead of updating SiteConfig after Function App is created. Though future update on site configs will be using update method.
  2. Some property values are different, e.g. kind in SiteInner need to be "functionapp,linux,container,azurecontainerapps"
  3. Some update methods(updateSiteConfig, updateAppSettings) are LRO for Centauri Function Apps, but not defined as such in swagger. Need to manual poll. 
### Tasks
- [x] Test cases for function app on ACA
- [x] Interface design
- [x] [Implementation investigation] SiteConfig behavior change
- [x] [Implementation investigation] SiteInner property modifications
- [x] [Implementation investigation] manual LRO for updating SiteConfig and AppSettings
- [x] Interface Implementation
- [x] Alpha release for tooling team
- [x] Stable release
weidongxu-microsoft commented 11 months ago

For (3), should we ask service to fix?

LRO not marked as LRO means every SDK fails.

XiaofeiCao commented 11 months ago

For (3), should we ask service to fix?

LRO not marked as LRO means every SDK fails.

Yeah, I'll ask them for confirmation. CLI team seems to be aware of this issue too: https://github.com/Azure/azure-cli/blob/dev/src/azure-cli/azure/cli/command_modules/appservice/custom.py#L1558

XiaofeiCao commented 10 months ago

Use cases for function app on Azure Container Apps

Create function app with managed environment

FunctionApp functionApp = appServiceManager.functionApps().define(webappName)
    .withRegion(Region.US_EAST)
    .withNewResourceGroup(rgName1)
    .withManagedEnvironmentId(managedEnvironmentId) // create with managedEnvironmentId
    //.withManagedEnvironmentName(managedEnvironmentName) // create with managedEnvironmentName
    .withMaxReplicas(10) // with scale setting
    .withMinReplicas(3) // with scale setting
    .withBuiltInImage(FunctionRuntimeStack.JAVA_17)
    .withAppSetting("WEBSITE_RUN_FROM_PACKAGE", FUNCTION_APP_PACKAGE_URL)
    .create();

Update scale settings

functionApp.update()
    .withMaxReplicas(15) // with scale setting
    .withMinReplicas(5) // with scale setting
    .apply();
XiaofeiCao commented 9 months ago

2.34.0 released.