in src/Cli/func/Actions/ContainerService/AzureContainerAppsDeployAction.cs [65:157]
public override async Task RunAsync()
{
ValidateParameters();
(var resolvedImageName, var shouldBuild) = ResolveImageName();
WorkerRuntime workerRuntime;
if (BuildImage && shouldBuild)
{
if (CurrentPathHasLocalSettings())
{
await _createFunctionAction.UpdateLanguageAndRuntime();
workerRuntime = _createFunctionAction.WorkerRuntime;
}
else
{
throw new CliException("The image cannot be built. Please run the command from the project folder. ");
}
await DockerHelpers.DockerBuild(resolvedImageName, Environment.CurrentDirectory);
await DockerHelpers.DockerPush(resolvedImageName, false);
}
else
{
if (!string.IsNullOrEmpty(WorkerRuntime) && Enum.TryParse<WorkerRuntime>(WorkerRuntime, true, out workerRuntime) && WorkerRuntimeLanguageHelper.AvailableWorkersList.ToList().Contains(workerRuntime))
{
workerRuntime = Enum.Parse<WorkerRuntime>(WorkerRuntime);
}
else
{
if (!string.IsNullOrEmpty(WorkerRuntime))
{
ColoredConsole.WriteLine(WarningColor($"WorkerRuntime '{WorkerRuntime}' is not valid."));
}
SelectionMenuHelper.DisplaySelectionWizardPrompt("worker runtime");
IDictionary<WorkerRuntime, string> workerRuntimeToDisplayString = WorkerRuntimeLanguageHelper.GetWorkerToDisplayStrings();
string workerRuntimedisplay = SelectionMenuHelper.DisplaySelectionWizard(workerRuntimeToDisplayString.Values);
workerRuntime = workerRuntimeToDisplayString.FirstOrDefault(wr => wr.Value.Equals(workerRuntimedisplay)).Key;
ColoredConsole.Write(Environment.NewLine);
}
}
var workerRuntimeName = WorkerRuntimeLanguageHelper.GetRuntimeMoniker(workerRuntime);
(var managedEnvironmentId, var environmentLocation) = await AzureHelper.GetManagedEnvironmentInfo(AccessToken, ManagementURL, Subscription, ResourceGroup, ManagedEnvironmentName);
if (string.IsNullOrEmpty(managedEnvironmentId))
{
throw new CliException($"The environment \"{ManagedEnvironmentName}\" couldn't be found.");
}
if (string.IsNullOrEmpty(Location) || Location == environmentLocation)
{
Location = environmentLocation;
}
else if (environmentLocation != "eastasia" || !Location.Contains("eastasia"))
{
throw new CliException($"Location \"{Location}\" should match with that of environment's \"{environmentLocation}\".");
}
var registryHost = GetHostNameFromRegistry();
var payload = ContainerAppsFunctionPayload.CreateInstance(Name, Location, managedEnvironmentId, $"DOCKER|{resolvedImageName}", StorageAccountConnectionString, workerRuntimeName, registryHost, RegistryUserName, RegistryPassword);
var hostName = await AzureHelper.CreateFunctionAppOnContainerService(AccessToken, ManagementURL, Subscription, ResourceGroup, payload);
ColoredConsole.Write("Getting Function App information..");
Arm.Models.Site functionApp = null;
for (int i = 0; functionApp == null && i < 12; i++)
{
try
{
Console.Write(".");
await Task.Delay(10000);
functionApp = await AzureHelper.GetFunctionApp(payload.Name, AccessToken, ManagementURL, defaultSubscription: Subscription, loadFunction: AzureHelper.LoadFunctionAppInContainerApp);
}
catch (ArmResourceNotFoundException)
{
continue;
}
}
ColoredConsole.Write(Environment.NewLine);
if (functionApp != null)
{
if (string.IsNullOrEmpty(functionApp.HostName))
{
functionApp.HostName = hostName;
}
await AzureHelper.PrintFunctionsInfo(functionApp, AccessToken, ManagementURL, showKeys: true);
}
}