Я пытаюсь развернуть приложение ASP.NET облако Windows Azure. Я использую Google API для одного из вызовов в приложении. Когда я делаю это, я получаю следующее сообщение об ошибке:Развертывание ASP.NET для Windows Azure облако, приложение дает ошибку при запуске в облаке
System.UnauthorizedAccessException: Access to the path 'Google.Apis.Auth' is denied.`
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.`
To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.`
Я попытался исследовать это, но все предложения говорят об изменении параметров сервера IIS, которые я не считаю, что я доступ к, так как это работает в облако. Может ли кто-нибудь помочь?
EDIT: Вот код для функции, которая дает ошибку:
Async Function SpecialTest() As Task(Of String)
Dim credential As UserCredential
Dim clientSecretsPath As String = Server.MapPath("~/App_Data/client_secret.json")
Dim scopes As IList(Of String) = New List(Of String)()
scopes.Add(CalendarService.Scope.Calendar)
Dim stream As FileStream = New FileStream(clientSecretsPath, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Using stream
credential = Await GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, scopes, "user3", CancellationToken.None)
End Using
Dim baseInitializer = New BaseClientService.Initializer()
With baseInitializer
.HttpClientInitializer = credential
.ApplicationName = "P1"
End With
Dim service = New CalendarService(baseInitializer)
Dim Calendars = (Await service.CalendarList.List().ExecuteAsync()).Items()
Dim toReturn As String = "{""items"": ["
For Each firstCalendar As CalendarListEntry In Calendars
If firstCalendar IsNot Nothing Then
' Get all events from the first calendar.
Dim calEvents = Await service.Events.List(firstCalendar.Id).ExecuteAsync()
' DO SOMETHING
Dim items = calEvents.Items
'Return JsonConvert.SerializeObject(calEvents)
For Each ite As Google.Apis.Calendar.v3.Data.Event In items
If Not (ite.Location Is Nothing) And Not (ite.Start Is Nothing) Then
Dim tst = ite.Start.DateTime
toReturn = toReturn + " [""" + Date.Parse(ite.Start.DateTime).ToShortDateString + """" + "," + """" + ite.Location + """" + "," + """" + ite.Start.DateTime + """" + "," + """" + ite.Start.DateTime + """" + "," + """""],"
End If
Next
End If
Next
toReturn = toReturn.Substring(0, toReturn.Length - 1)
Return toReturn + "]}"
End Function`
Прежде чем приступать к ответу, можете ли вы подробно рассказать о вызове API Google? Ожидаете ли вы, что он взаимодействует с известным/неизвестным местоположением в файловой системе (как кажется)? – DavideB
@DavideB Я действительно так не думал, есть 2 вызова, первый для аутентификации через Oauth, а второй использует API календаря для извлечения определенных данных из Календаря Google. Он читает JSON-файл как часть процедуры, не уверен, что это считается «взаимодействием с файловой системой». –
Описанный файл JSON физически находится в файловой системе? Например, где он находится, когда вы тестируете его локально в структуре разработки? – DavideB