Skip to content

Commit

Permalink
Fix issue with template not deploying correct version of Functions. A…
Browse files Browse the repository at this point in the history
…lso, add lots of other functional improvements to the ARM template and apply simplificiations elsewhere (#111)
  • Loading branch information
Careyjmac committed Jul 12, 2021
1 parent 9ba4234 commit 5daab18
Show file tree
Hide file tree
Showing 9 changed files with 289 additions and 321 deletions.
3 changes: 1 addition & 2 deletions JfkWebApiSkills/JfkInitializer/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

<!--Keys related to your Azure Function instance-->
<add key="AzureFunctionSiteName" value="" />
<add key="AzureFunctionUsername" value="" />
<add key="AzureFunctionPassword" value="" />
<add key="AzureFunctionHostKey" value="" />

<!--Location of sample JFK file documents that we are providing to you.-->
<add key="JFKFilesBlobStorageAccountConnectionString" value="SharedAccessSignature=st=2019-05-02T21%3A30%3A00Z&amp;se=9999-12-21T12%3A00%3A00Z&amp;sp=rl&amp;sv=2018-03-28&amp;sr=c&amp;sig=NmOktoltvmd9gLqHidRuQN06xeSXbCVYIVti5prLdmA%3D;BlobEndpoint=https://azsjfkfiles.blob.core.windows.net/" />
Expand Down
1 change: 0 additions & 1 deletion JfkWebApiSkills/JfkInitializer/JfkInitializer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="KeyHelper.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SearchResources.cs" />
Expand Down
31 changes: 0 additions & 31 deletions JfkWebApiSkills/JfkInitializer/KeyHelper.cs

This file was deleted.

4 changes: 2 additions & 2 deletions JfkWebApiSkills/JfkInitializer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private static async Task<bool> CreateSkillSet()
Console.WriteLine("Creating Skill Set...");
try
{
Skillset skillset = SearchResources.GetSkillset(SkillsetName, await KeyHelper.GetAzureFunctionHostKey(_httpClient), BlobContainerNameForImageStore);
Skillset skillset = SearchResources.GetSkillset(SkillsetName, BlobContainerNameForImageStore);
await _searchClient.Skillsets.CreateAsync(skillset);
}
catch (Exception ex)
Expand Down Expand Up @@ -258,7 +258,7 @@ private static async Task<bool> DeployWebsite()
envText = envText.Replace("[SearchServiceApiKey]", searchQueryKey);
envText = envText.Replace("[SearchServiceApiVersion]", _searchClient.ApiVersion);
envText = envText.Replace("[AzureFunctionName]", ConfigurationManager.AppSettings["AzureFunctionSiteName"]);
envText = envText.Replace("[AzureFunctionDefaultHostKey]", await KeyHelper.GetAzureFunctionHostKey(_httpClient));
envText = envText.Replace("[AzureFunctionDefaultHostKey]", ConfigurationManager.AppSettings["AzureFunctionHostKey"]);
File.WriteAllText("../../../../frontend/.env", envText);

Console.WriteLine("Website keys have been set. Please build the website and then return here and press any key to continue.");
Expand Down
8 changes: 4 additions & 4 deletions JfkWebApiSkills/JfkInitializer/SearchResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static DataSource GetDataSource(string name) =>
description: "Data source for cognitive search example"
);

public static Skillset GetSkillset(string name, string azureFunctionHostKey, string blobContainerNameForImageStore)
public static Skillset GetSkillset(string name, string blobContainerNameForImageStore)
{
string azureFunctionEndpointUri = string.Format("https://{0}.azurewebsites.net", ConfigurationManager.AppSettings["AzureFunctionSiteName"]);
return new Skillset()
Expand Down Expand Up @@ -160,7 +160,7 @@ public static Skillset GetSkillset(string name, string azureFunctionHostKey, str
{
Description = "Upload image data to the annotation store",
Context = "/document/normalized_images/*",
Uri = string.Format("{0}/api/image-store?code={1}", azureFunctionEndpointUri, azureFunctionHostKey),
Uri = string.Format("{0}/api/image-store?code={1}", azureFunctionEndpointUri, ConfigurationManager.AppSettings["AzureFunctionHostKey"]),
HttpHeaders = new Dictionary<string, string>()
{
["BlobContainerName"] = blobContainerNameForImageStore
Expand All @@ -179,7 +179,7 @@ public static Skillset GetSkillset(string name, string azureFunctionHostKey, str
{
Description = "Generate HOCR for webpage rendering",
Context = "/document",
Uri = string.Format("{0}/api/hocr-generator?code={1}", azureFunctionEndpointUri, azureFunctionHostKey),
Uri = string.Format("{0}/api/hocr-generator?code={1}", azureFunctionEndpointUri, ConfigurationManager.AppSettings["AzureFunctionHostKey"]),
BatchSize = 1,
Inputs = new List<InputFieldMappingEntry>()
{
Expand All @@ -195,7 +195,7 @@ public static Skillset GetSkillset(string name, string azureFunctionHostKey, str
{
Description = "Cryptonym linker",
Context = "/document",
Uri = string.Format("{0}/api/link-cryptonyms-list?code={1}", azureFunctionEndpointUri, azureFunctionHostKey),
Uri = string.Format("{0}/api/link-cryptonyms-list?code={1}", azureFunctionEndpointUri, ConfigurationManager.AppSettings["AzureFunctionHostKey"]),
BatchSize = 1,
Inputs = new List<InputFieldMappingEntry>()
{
Expand Down
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,23 @@ These instructions will help you have your own version of the JFK files demo run

![Outputs of deployment](images/outputs.JPG)

9. Copy and paste each of the provided outputs from this interface into their corresponding value location in the *App.config* file from before. Note that one value will be missing from the outputs, the *SearchServiceQueryKey*.
10. In order to obtain the *SearchServiceQueryKey*, navigate back to the *Overview* section of the deployment and find your newly created Azure Search service in the list (Its type will be *Microsoft.Search/searchServices*). Select it.
9. Copy and paste each of the provided outputs from this interface into their corresponding value location in the *App.config* file from before.

![Search service in deployment](images/searchServiceInDeployment.JPG)

11. Select the *Keys* section, followed by *Manage query keys*. Copy and paste the key value shown into the *SearchServiceQueryKey* value of your *App.config* file.

![Search service keys](images/searchServiceKeys.JPG)

12. Now you should have filled in all of the required configurations in the *App.config* file. Save your changes, and press the start button at the top of Visual Studio in order to run the initializer.
10. Save your changes to the *App.config* file, and press the start button at the top of Visual Studio in order to run the initializer.

![Run initializer](images/runInitializer.JPG)

13. After a few seconds, the message "Website keys have been set. Please build the website and then return here and press any key to continue." will be output to the console app. At this point, open a separate cmd window and cd into the directory of where you cloned or downloaded the repo. Then run the following commands:
11. After a few seconds, the message "Website keys have been set. Please build the website and then return here and press any key to continue." will be output to the console app. At this point, open a separate cmd window and cd into the directory of where you cloned or downloaded the repo. Then run the following commands:

```shell
cd frontend
npm install
npm run build:prod
```

14. After the commands finish running, return to the console app and press any key to continue.
12. After the commands finish running, return to the console app and press any key to continue.

15. Once the website is deployed, a URL will appear in the console. Copy and paste this URL into a browser to start interacting with what you have created!
13. Once the website is deployed, a URL will appear in the console. Copy and paste this URL into a browser to start interacting with what you have created!

![URL in console](images/urlInConsole.JPG)

Expand Down
Loading

0 comments on commit 5daab18

Please sign in to comment.