Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<RootNamespace>IsolatedModel_BidirectionChat</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.12" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.SignalRService" Version="1.7.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" OutputItemType="Analyzer" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.5.2" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.3.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.SignalRService" Version="1.15.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.1" OutputItemType="Analyzer" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
Expand Down
24 changes: 23 additions & 1 deletion samples/DotnetIsolated-BidirectionChat/Functions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.IO;
using System.Net;
using Microsoft.Azure.Functions.Worker;
Expand All @@ -19,7 +20,28 @@ public Functions(ILoggerFactory loggerFactory)
public HttpResponseData GetWebPage([HttpTrigger(AuthorizationLevel.Anonymous)] HttpRequestData req)
{
var response = req.CreateResponse(HttpStatusCode.OK);
response.WriteString(File.ReadAllText("content/index.html"));
string content;
string home = Environment.GetEnvironmentVariable("HOME");
if (!string.IsNullOrEmpty(home))
{
string htmlFilePath = Path.Combine(home, "site", "wwwroot", "content", "index.html");
if (File.Exists(htmlFilePath))
{
// When running on Azure
content = File.ReadAllText(htmlFilePath);
}
else
{
// Assume the function is running locally with function core tools
content = File.ReadAllText("content/index.html");
}
}
else
{
// Assume the function is running locally with function core tools
content = File.ReadAllText("content/index.html");
}
response.WriteString(content);
response.Headers.Add("Content-Type", "text/html");
return response;
}
Expand Down
3 changes: 0 additions & 3 deletions samples/DotnetIsolated-BidirectionChat/content/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ <h3>Serverless chat</h3>
throw "No username entered";
}
getConnectionInfo().then(info => {
// make compatible with old and new SignalRConnectionInfo
info.accessToken = info.AccessToken || info.accessKey; // pay attention to the case
info.url = info.Url || info.endpoint; // pay attention to the case
data.ready = true;
const options = {
accessTokenFactory: () => info.accessToken
Expand Down
24 changes: 21 additions & 3 deletions samples/DotnetIsolated-ClassBased/Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,31 @@ public Functions(IServiceProvider serviceProvider, ILogger<Functions> logger) :
public HttpResponseData GetWebPage([HttpTrigger(AuthorizationLevel.Anonymous)] HttpRequestData req)
{
var response = req.CreateResponse(HttpStatusCode.OK);
string content;
string home = Environment.GetEnvironmentVariable("HOME");
string htmlFilePath = Path.Combine(home, "site", "wwwroot", "content", "index.html");
response.WriteString(File.ReadAllText(htmlFilePath));
if (!string.IsNullOrEmpty(home))
{
string htmlFilePath = Path.Combine(home, "site", "wwwroot", "content", "index.html");
if (File.Exists(htmlFilePath))
{
// When running on Azure
content = File.ReadAllText(htmlFilePath);
}
else
{
// Assume the function is running locally with function core tools
content = File.ReadAllText("content/index.html");
}
}
else
{
// Assume the function is running locally with function core tools
content = File.ReadAllText("content/index.html");
}
response.WriteString(content);
response.Headers.Add("Content-Type", "text/html");
return response;
}

[Function("negotiate")]
public async Task<HttpResponseData> Negotiate([HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequestData req)
{
Expand Down