6

I have the following requirement,

When an URL is requested in the azure web site for a file, then the file available in root folder has to return to "application/JSON"

Say for example:

I have a file called "apple-app-site-association", which is a text file which has JsonData available in the root folder of a web site in azure. When we enter the URL in browser "mydomain.com\appleConfiguration", that should return the JSON text in the browser.

The file "apple-app-site-association" should not have the extension of ".Json"

I tried using the following ruleset in the web.config, believe the rule set is not accurate, can some one suggest this.

This works fine in IIS but not in Azure hosted site.

 <rule name="Apple Universal Links" stopProcessing="true">
          <match url="^apple-app-site-association$"/>
          <action type="Redirect"  redirectType="application/json" url="^apple-app-site-association$"/>
         </rule>
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Ipsita Sethi
  • 462
  • 4
  • 15

3 Answers3

9

Follow the simple five steps to make this working,

1) Create the "apple-app-site-association" with the mobile configuration JSON content and store to the local system.

Sample configuration in the file "apple-app-site-association":

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "9JA89QQLNQ.com.apple.wwdc",
                "paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"]
            },
            {
                "appID": "ABCD1234.com.apple.wwdc",
                "paths": [ "*" ]
            }
        ]
    }
}

2) Copy the.Json file to your root directory of the azure folder "wwwroot"

3) If the json file is not available or protected to read in your website, then use the mime configuration to enable the .json file to display in the web site

<staticContent> 
          <mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent> 

4) Create a rule in the "web.config" file, which will provide the Json value when the Applebot robot crawl your site for the apple association

<system.webServer>


<rewrite>
      <rules>
        <rule name="apple_json_file">
                    <match url="^apple-app-site-association" />
                    <action type="Rewrite" url="apple-app-site-association.json" />
                </rule>
      </rules>

</rewrite>




</system.webServer> 

5) Check the Json value is displayed in your web site properly, when you enter the following URL in browser,

https://yourDomain/apple-app-site-association

or

http://branch.io/resources/aasa-validator/

Note: Modify the with valid website Domain name.

if this works fine then Go to the validator site

https://search.developer.apple.com/appsearch-validation-tool

Check the Universal links are valid for your web site.

enter image description here

BHUVANESH MOHANKUMAR
  • 2,747
  • 1
  • 33
  • 33
  • 1
    This is also the site where the Universal links can be validated. http://branch.io/resources/aasa-validator/ – BHUVANESH MOHANKUMAR Mar 27 '17 at 20:36
  • 2
    SSL certificate is mandate for Universal deep linking and also "AppleBot" robot.txt should able to crawl your web site, if not then it will not be validated by apple validator. – Ipsita Sethi Mar 27 '17 at 20:52
  • Just worth noting that that section also goes in the web.config section and that you may need to remove existing rules by first using the following: before the mimeMap tag – CF5 Feb 15 '18 at 13:33
0

I want to add my state into previous answer by Bhuvnesh Mohankumar.

In step #2, after copy "apple-app-site-association" file in wwwroot, we are unable to validate our AASA file on step #5.

So here is my find for this issue as below.

If by following all the steps and any still facing the issue in validating AASA file, please copy two files "apple-app-site-association" and "apple-app-site-association.json" in wwwroot azure server.

K.D
  • 516
  • 3
  • 14
0

For what it is worth, I was doing this via an Azure web app and found this to work like a charm in Startup.cs::Configure

            var options = new RewriteOptions()
                .AddRewrite(@"^.well-known/apple-app-site-association", ".well-known/apple-app-site-association.json",
                    skipRemainingRules: true);

            app.UseRewriter(options);
Lazy Coder
  • 1,157
  • 1
  • 8
  • 18