Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
soninaren committed Aug 22, 2019
2 parents 93d40b1 + 2edcab8 commit 9a2b723
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,6 @@ private async Task PublishFunctionApp(Site functionApp, GitIgnoreParser ignorePa

// For dedicated linux apps, we do not support run from package right now
var isFunctionAppDedicatedLinux = functionApp.IsLinux && !functionApp.IsDynamic && !functionApp.IsElasticPremium;
if (isFunctionAppDedicatedLinux && RunFromPackageDeploy && PublishBuildOption != BuildOption.Remote)
{
ColoredConsole.WriteLine("Assuming --nozip (do not run from package) for publishing to Linux dedicated plan.");
RunFromPackageDeploy = false;
}

// For Python linux apps, we do not support --build remote with --build-native-deps flag
if (PublishBuildOption == BuildOption.Remote && BuildNativeDeps)
Expand Down Expand Up @@ -399,7 +394,7 @@ private async Task HandleLinuxDedicatedPublish(Func<Task<Stream>> zipStreamFacto
if (PublishBuildOption != BuildOption.Remote)
{
await EnsureNoKuduLiteBuildSettings(functionApp);
await PublishZipDeploy(functionApp, zipStreamFactory);
await PublishRunFromPackageLocal(functionApp, zipStreamFactory);
return;
}

Expand Down Expand Up @@ -637,8 +632,8 @@ public async Task<DeployStatus> PerformServerSideBuild(Site functionApp, Func<Ta
{
if (string.IsNullOrEmpty(functionApp.ScmUri))
{
throw new CliException($"Your function app {functionApp.SiteName} does not support remote build. " +
"To enable remote build, please update your function app to the latest verison by recreating it.");
throw new CliException("Remote build is a new feature added to function apps. " +
$"Your function app {functionApp.SiteName} does not support remote build as it was created before August 1st, 2019.");
}

using (var handler = new ProgressMessageHandler(new HttpClientHandler()))
Expand Down
15 changes: 11 additions & 4 deletions src/Azure.Functions.Cli/Actions/LocalActions/InitAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public override async Task RunAsync()

private async Task InitDockerFileOnly()
{
await WriteDockerfile(GlobalCoreToolsSettings.CurrentWorkerRuntime);
await WriteDockerfile(GlobalCoreToolsSettings.CurrentWorkerRuntime, Csx);
}

private async Task InitFunctionAppProject()
Expand Down Expand Up @@ -181,7 +181,7 @@ private async Task InitFunctionAppProject()
}
if (InitDocker)
{
await WriteDockerfile(workerRuntime);
await WriteDockerfile(workerRuntime, Csx);
}
}

Expand Down Expand Up @@ -301,11 +301,18 @@ private static async Task WriteLocalSettingsJson(WorkerRuntime workerRuntime)
await WriteFiles("local.settings.json", localSettingsJsonContent);
}

private static async Task WriteDockerfile(WorkerRuntime workerRuntime)
private static async Task WriteDockerfile(WorkerRuntime workerRuntime, bool csx)
{
if (workerRuntime == Helpers.WorkerRuntime.dotnet)
{
await WriteFiles("Dockerfile", await StaticResources.DockerfileDotNet);
if (csx)
{
await WriteFiles("Dockerfile", await StaticResources.DockerfileCsxDotNet);
}
else
{
await WriteFiles("Dockerfile", await StaticResources.DockerfileDotNet);
}
}
else if (workerRuntime == Helpers.WorkerRuntime.node)
{
Expand Down
5 changes: 4 additions & 1 deletion src/Azure.Functions.Cli/Azure.Functions.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<EmbeddedResource Include="StaticResources\ExtensionsProj.csproj.template">
<LogicalName>$(AssemblyName).ExtensionsProj.csproj</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.csx.dotnet">
<LogicalName>$(AssemblyName).Dockerfile.csx.dotnet</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.dotnet">
<LogicalName>$(AssemblyName).Dockerfile.dotnet</LogicalName>
</EmbeddedResource>
Expand Down Expand Up @@ -111,7 +114,7 @@
<PackageReference Include="Microsoft.Azure.Functions.NodeJsWorker" Version="1.0.3" />
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker" Version="0.1.152-preview" />
<PackageReference Include="Microsoft.Azure.WebJobs.Script.WebHost" Version="2.0.12641" />
<PackageReference Include="Microsoft.Azure.Functions.PythonWorkerRunEnvironments" Version="1.0.0-beta20190801.11" />
<PackageReference Include="Microsoft.Azure.Functions.PythonWorkerRunEnvironments" Version="1.0.0-beta20190816.7" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="YamlDotNet" Version="6.0.0" />
</ItemGroup>
Expand Down
22 changes: 15 additions & 7 deletions src/Azure.Functions.Cli/Helpers/KuduLiteDeploymentHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,23 @@ public static async Task<DeployStatus> WaitForDedicatedBuildToComplete(HttpClien
ColoredConsole.Write("Remote build in progress, please wait");
while (true)
{
var json = await InvokeRequest<IDictionary<string, bool>>(client, HttpMethod.Get, "/api/isdeploying");
bool isDeploying = json["value"];
if (!isDeploying)
var json = await InvokeRequest<IDictionary<string, string>>(client, HttpMethod.Get, "/api/isdeploying");

if (bool.TryParse(json["value"], out bool isDeploying))
{
if (!isDeploying)
{
string deploymentId = await GetLatestDeploymentId(client, functionApp, restrictedToken: null);
DeployStatus status = await GetDeploymentStatusById(client, functionApp, restrictedToken: null, id: deploymentId);
ColoredConsole.Write($"done{Environment.NewLine}");
return status;
}
}
else
{
string deploymentId = await GetLatestDeploymentId(client, functionApp, restrictedToken: null);
DeployStatus status = await GetDeploymentStatusById(client, functionApp, restrictedToken: null, id: deploymentId);
ColoredConsole.Write($"done{Environment.NewLine}");
return status;
throw new CliException($"Expected \"value\" from /api/isdeploying endpoing to be a boolean. Actual: {json["value"]}");
}

ColoredConsole.Write(".");
await Task.Delay(5000);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ public static class WorkerRuntimeLanguageHelper
case WorkerRuntime.powershell:
workerToDisplayStrings[wr] = "powershell (preview)";
break;
case WorkerRuntime.python:
workerToDisplayStrings[wr] = "python (preview)";
break;
default:
workerToDisplayStrings[wr] = wr.ToString();
break;
Expand Down
5 changes: 5 additions & 0 deletions src/Azure.Functions.Cli/StaticResources/Dockerfile.csx.dotnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM mcr.microsoft.com/azure-functions/dotnet:2.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY . /home/site/wwwroot
2 changes: 2 additions & 0 deletions src/Azure.Functions.Cli/StaticResources/StaticResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ private static async Task<string> GetValue(string name)

public static Task<string> DockerfileDotNet => GetValue("Dockerfile.dotnet");

public static Task<string> DockerfileCsxDotNet => GetValue("Dockerfile.csx.dotnet");

public static Task<string> DockerfilePython => GetValue("Dockerfile.python");

public static Task<string> DockerfileNode => GetValue("Dockerfile.node");
Expand Down
42 changes: 42 additions & 0 deletions test/Azure.Functions.Cli.Tests/E2E/InitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@ public Task init_with_Dockerfile(string workerRuntime)
}, _output);
}

[Fact]
public Task init_with_Dockerfile_for_csx()
{
return CliTester.Run(new RunConfiguration
{
Commands = new[] { $"init . --worker-runtime dotnet --docker --csx" },
CheckFiles = new[]
{
new FileResult
{
Name = "Dockerfile",
ContentNotContains = new[] { "dotnet publish" },
ContentContains = new[] { $"FROM mcr.microsoft.com/azure-functions/dotnet:2.0" }
}
},
OutputContains = new[] { "Dockerfile" }
}, _output);
}

[Fact]
public Task init_csx_app()
{
Expand Down Expand Up @@ -293,6 +312,29 @@ public Task init_docker_only_for_existing_project(string workerRuntime)
}, _output);
}

[Fact]
public Task init_docker_only_for_csx_project()
{
return CliTester.Run(new RunConfiguration
{
Commands = new[]
{
$"init . --worker-runtime dotnet --csx",
$"init . --docker-only --csx",
},
CheckFiles = new[]
{
new FileResult
{
Name = "Dockerfile",
ContentNotContains = new[] { "dotnet publish" },
ContentContains = new[] { $"FROM mcr.microsoft.com/azure-functions/dotnet:2.0" }
}
},
OutputContains = new[] { "Dockerfile" }
}, _output);
}

[Fact]
public Task init_docker_only_no_project()
{
Expand Down

0 comments on commit 9a2b723

Please sign in to comment.