Skip to content

Throwing exception when service plan is not created#43

Closed
LavanyaK235 wants to merge 1 commit intomainfrom
users/kalavany/36004236
Closed

Throwing exception when service plan is not created#43
LavanyaK235 wants to merge 1 commit intomainfrom
users/kalavany/36004236

Conversation

@LavanyaK235
Copy link
Contributor

Throwing exception when service plan is not created

Copilot AI review requested due to automatic review settings November 24, 2025 19:13
@LavanyaK235 LavanyaK235 requested review from a team as code owners November 24, 2025 19:13
Copy link
Contributor

@Josina20 Josina20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is going to be deleted in this PR - #38. We can push the changes to the new branch or wait till the changes are checked in

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves error handling when creating Azure App Service plans by extracting the creation logic into a separate testable method and adding explicit verification that the plan was successfully created. Previously, if plan creation failed silently (e.g., due to quota limits or permission issues), the setup would continue without detecting the problem.

Key Changes:

  • Extracted App Service plan creation logic into EnsureAppServicePlanExistsAsync method with post-creation verification
  • Added comprehensive test coverage for various failure scenarios (quota limits, permission denied, silent failures)
  • Added InternalsVisibleTo attribute to enable testing of internal methods

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Microsoft.Agents.A365.DevTools.Cli/Services/A365SetupRunner.cs Extracted inline App Service plan creation into new EnsureAppServicePlanExistsAsync method that verifies plan existence after creation and throws exception on failure
src/Tests/Microsoft.Agents.A365.DevTools.Cli.Tests/Services/A365SetupRunnerTests.cs Added comprehensive test suite covering successful creation, existing plans, quota limit errors, permission errors, and silent failures
src/Microsoft.Agents.A365.DevTools.Cli/Microsoft.Agents.A365.DevTools.Cli.csproj Added InternalsVisibleTo for test project to access internal method

Comment on lines +1800 to +1807
await AzWarnAsync($"appservice plan create -g {resourceGroup} -n {planName} --sku {planSku} --is-linux --subscription {subscriptionId}", "Create App Service plan");

// Verify the plan was created successfully
var verifyPlan = await _executor.ExecuteAsync("az", $"appservice plan show -g {resourceGroup} -n {planName} --subscription {subscriptionId}", captureOutput: true, suppressErrorLogging: true);
if (!verifyPlan.Success)
{
_logger.LogError("ERROR: App Service plan creation failed. The plan '{Plan}' does not exist.", planName);
throw new InvalidOperationException($"Failed to create App Service plan '{planName}'. This may be due to quota limits or insufficient permissions. Setup cannot continue.");
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error details from the failed App Service plan creation are lost when throwing the exception. Consider capturing the result from AzWarnAsync or directly calling _executor.ExecuteAsync to access result.StandardError, which would provide more specific error information (e.g., quota limits vs. permissions) to include in the exception message.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants