Skip to content

Commit

Permalink
Fix pr#36447 mgmt, fix samples for appservice (#39423)
Browse files Browse the repository at this point in the history
  • Loading branch information
v-hongli1 committed Mar 28, 2024
1 parent 55ccc93 commit 2c2a540
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.azure.core.management.AzureEnvironment;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.resourcemanager.AzureResourceManager;
import com.azure.resourcemanager.appservice.fluent.models.CsmPublishingCredentialsPoliciesEntityProperties;
import com.azure.resourcemanager.appservice.models.FtpsState;
import com.azure.resourcemanager.appservice.models.FunctionApp;
import com.azure.resourcemanager.appservice.models.LogLevel;
import com.azure.core.management.Region;
Expand Down Expand Up @@ -61,11 +63,23 @@ public static boolean runSample(AzureResourceManager azureResourceManager) throw
.withLogLevel(LogLevel.VERBOSE)
.withApplicationLogsStoredOnFileSystem()
.attach()
.withFtpsState(FtpsState.ALL_ALLOWED)
.create();

System.out.println("Created function app " + app.name());
Utils.print(app);

app.manager().resourceManager().genericResources().define("ftp")
.withRegion(app.regionName())
.withExistingResourceGroup(app.resourceGroupName())
.withResourceType("basicPublishingCredentialsPolicies")
.withProviderNamespace("Microsoft.Web")
.withoutPlan()
.withParentResourcePath("sites/" + app.name())
.withApiVersion("2023-01-01")
.withProperties(new CsmPublishingCredentialsPoliciesEntityProperties().withAllow(true))
.create();

//============================================================
// Deploy to app 1 through FTP

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import com.azure.core.management.AzureEnvironment;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.resourcemanager.AzureResourceManager;
import com.azure.resourcemanager.appservice.fluent.models.CsmPublishingCredentialsPoliciesEntityProperties;
import com.azure.resourcemanager.appservice.models.ConnectionStringType;
import com.azure.resourcemanager.appservice.models.FtpsState;
import com.azure.resourcemanager.appservice.models.PricingTier;
import com.azure.resourcemanager.appservice.models.RuntimeStack;
import com.azure.resourcemanager.appservice.models.WebApp;
Expand Down Expand Up @@ -101,11 +103,23 @@ public static boolean runSample(AzureResourceManager azureResourceManager) {
.withBuiltInImage(RuntimeStack.TOMCAT_8_5_JRE8)
.withConnectionString("storage.connectionString", connectionString, ConnectionStringType.CUSTOM)
.withAppSetting("storage.containerName", containerName)
.withFtpsState(FtpsState.ALL_ALLOWED)
.create();

System.out.println("Created web app " + app1.name());
Utils.print(app1);

app1.manager().resourceManager().genericResources().define("ftp")
.withRegion(app1.regionName())
.withExistingResourceGroup(app1.resourceGroupName())
.withResourceType("basicPublishingCredentialsPolicies")
.withProviderNamespace("Microsoft.Web")
.withoutPlan()
.withParentResourcePath("sites/" + app1.name())
.withApiVersion("2023-01-01")
.withProperties(new CsmPublishingCredentialsPoliciesEntityProperties().withAllow(true))
.create();

//============================================================
// Deploy a web app that connects to the storage account
// Source code: https://github.com/jianghaolu/azure-samples-blob-explorer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.azure.core.util.Configuration;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.resourcemanager.AzureResourceManager;
import com.azure.resourcemanager.appservice.fluent.models.CsmPublishingCredentialsPoliciesEntityProperties;
import com.azure.resourcemanager.appservice.models.FtpsState;
import com.azure.resourcemanager.appservice.models.JavaVersion;
import com.azure.resourcemanager.appservice.models.PricingTier;
import com.azure.resourcemanager.appservice.models.WebApp;
Expand Down Expand Up @@ -111,11 +113,23 @@ public static boolean runSample(AzureResourceManager azureResourceManager, Strin
.withWebContainer(WebContainer.TOMCAT_8_5_NEWEST)
.withAppSetting("AZURE_KEYVAULT_URI", vault.vaultUri())
.withSystemAssignedManagedServiceIdentity()
.withFtpsState(FtpsState.ALL_ALLOWED)
.create();

System.out.println("Created web app " + app.name());
Utils.print(app);

app.manager().resourceManager().genericResources().define("ftp")
.withRegion(app.regionName())
.withExistingResourceGroup(app.resourceGroupName())
.withResourceType("basicPublishingCredentialsPolicies")
.withProviderNamespace("Microsoft.Web")
.withoutPlan()
.withParentResourcePath("sites/" + app.name())
.withApiVersion("2023-01-01")
.withProperties(new CsmPublishingCredentialsPoliciesEntityProperties().withAllow(true))
.create();

//============================================================
// Update vault to allow the web app to access

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import com.azure.core.management.AzureEnvironment;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.resourcemanager.AzureResourceManager;
import com.azure.resourcemanager.appservice.fluent.models.CsmPublishingCredentialsPoliciesEntityProperties;
import com.azure.resourcemanager.appservice.models.ConnectionStringType;
import com.azure.resourcemanager.appservice.models.FtpsState;
import com.azure.resourcemanager.appservice.models.JavaVersion;
import com.azure.resourcemanager.appservice.models.PricingTier;
import com.azure.resourcemanager.appservice.models.WebApp;
Expand Down Expand Up @@ -102,11 +104,23 @@ public static boolean runSample(AzureResourceManager azureResourceManager) {
.withWebContainer(WebContainer.TOMCAT_8_0_NEWEST)
.withConnectionString("storage.connectionString", connectionString, ConnectionStringType.CUSTOM)
.withAppSetting("storage.containerName", containerName)
.withFtpsState(FtpsState.ALL_ALLOWED)
.create();

System.out.println("Created web app " + app1.name());
Utils.print(app1);

app1.manager().resourceManager().genericResources().define("ftp")
.withRegion(app1.regionName())
.withExistingResourceGroup(app1.resourceGroupName())
.withResourceType("basicPublishingCredentialsPolicies")
.withProviderNamespace("Microsoft.Web")
.withoutPlan()
.withParentResourcePath("sites/" + app1.name())
.withApiVersion("2023-01-01")
.withProperties(new CsmPublishingCredentialsPoliciesEntityProperties().withAllow(true))
.create();

//============================================================
// Deploy a web app that connects to the storage account
// Source code: https://github.com/jianghaolu/azure-samples-blob-explorer
Expand Down

0 comments on commit 2c2a540

Please sign in to comment.