2016-12-02 19 views
0

this blog postホームページの匿名アクセスを有効にしようとすると、このauthorization.jsonを使用して/ AdminページにアクセスするとGoogleにリダイレクトされます。Azure Appサービスの承認ルールが機能していません

{ 
    "routes": [ 
    { 
     "path_prefix": "/", 
     "policies": { "unauthenticated_action": "AllowAnonymous" } 
    }, 
    { 
     "path_prefix": "/Admin", 
     "policies": { "unauthenticated_action": "RedirectToLoginPage" } 
    } 
    ] 
} 

私はそれは常にログインページに私をナビゲートhttp://mysite.azurewebsites.net/ @ホーム・ページにアクセスします。私はログイン後、リダイレクト後、私はログストリーミングの中で次のエラーが発生しています。

2016-12-02T04:30:44 PID[11016] Verbose  [Routes(Preview)] Attempting to load configuration from 'D:\home\site\wwwroot\authorization.json'. 
2016-12-02T04:30:44 PID[11016] Critical System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type Microsoft.Azure.AppService.Routes.RoutesConfig. Encountered unexpected character 'ï'. ---> System.Xml.XmlException: Encountered unexpected character 'ï'. 
    at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, XmlException exception) 
    at System.Runtime.Serialization.Json.XmlJsonReader.ReadAttributes() 
    at System.Runtime.Serialization.Json.XmlJsonReader.ReadNonExistentElementName(StringHandleConstStringType elementName) 
    at System.Runtime.Serialization.Json.XmlJsonReader.Read() 
    at System.Xml.XmlBaseReader.IsStartElement() 
    at System.Xml.XmlBaseReader.IsStartElement(XmlDictionaryString localName, XmlDictionaryString namespaceUri) 
    at System.Runtime.Serialization.XmlReaderDelegator.IsStartElement(XmlDictionaryString localname, XmlDictionaryString ns) 
    at System.Runtime.Serialization.XmlObjectSerializer.IsRootElement(XmlReaderDelegator reader, DataContract contract, XmlDictionaryString name, XmlDictionaryString ns) 
    at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalIsStartObject(XmlReaderDelegator reader) 
    at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName) 
    at System.Runtime.Serialization.XmlObjectSerializer.InternalReadObject(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver) 
    at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver) 
    --- End of inner exception stack trace --- 
    at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver) 
    at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader) 
    at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(Stream stream) 
    at Microsoft.Azure.AppService.Authentication.ModuleUtils.DecodeJson[T](Stream jsonStream) 
    at Microsoft.Azure.AppService.Routes.RoutesConfig.TryLoadFromFile(String configFilePath, Func`2 deserializer, RoutesConfig& config) 
    at Microsoft.Azure.AppService.Routes.RoutesConfig.TryLoadFromJsonFile(String configFilePath, RoutesConfig& config) 
    at Microsoft.Azure.AppService.Routes.RoutesModule.TryLoadRoutesConfig(HttpContextBase context) 
    at Microsoft.Azure.AppService.Routes.RoutesModule.<OnPostAuthenticateRequestAsync>d__4.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.Azure.AppService.Authentication.HttpModuleDispatcher.<DispatchAsync>d__13.MoveNext() 
2016-12-02T04:30:44 PID[11016] Information Sending response: 500.79 Internal Server Error 

追加詳細。 1.上記のようにVisual Studioから公開した後、サイトを再起動しました。 2. AdminControllerの中にある/ Adminパス。 3. authorization.jsonはサイトのルートにあります。 PS D:\ home \ site \ wwwroot>に移動すると、私はauthorization.jsonファイルを見ることができます。

ファイルの構文に関して何が間違っているのか分かりません。

答えて

2

あなたの説明によると、URL Authorization Rulesに続き、私のVisual Studioでauthorization.jsonを作成しました。 Azure Web Appで期待どおりに動作させることができました。

https://bruce-chen-001.azurewebsites.net/

https://bruce-chen-001.azurewebsites.net/admin/admin.html

私はあなたのauthorization.jsonファイルに問題があることを想定。 Encountered unexpected character ‘ï’ error serializing JSONについても同様の問題が見つかりました。それを参照できます。

ここ

は私authorization.jsonファイルです更新:

あなたはが匿名を要求(アクション)を許可しないを選択したことを確認してください「アクションの下で取りますAzure Portal上のApp ServiceのAuthentication/Authorizationブレードで「要求が認証されていません」と表示されます。

+0

あなたがあなたのウェブサイトのために使用さauthorization.jsonファイルを含めるようにあなたの答えを更新することはできますか?私はmsdnの記事にその文字をクリアして再試行し、ウェブサイトを再起動したが、まだナビゲートしていない/匿名のログインを許可していない。 – Mitul

+0

@ミトル私は自分の答えを更新しました。私の更新を見てください。 –

+0

リクエストが認証されていないときに「Googleでログインする」と設定されている場合、行動する必要がありました。匿名の要求を許可する(何もしない)ように変更され、動作します。ありがとう。 – Mitul

関連する問題