2017-10-26 2 views
2

.Net Core 2.0의 Microsoft.WindowsAzure.Storage C# 라이브러리를 사용하고 있습니다. 내가 동적으로 푸른 저장 에뮬레이터에 CORS를 구성하려고 노력하지만 오류가있어이 라이브러리를 사용 :Azure 저장소 에뮬레이터 - CORS를 동적으로 구성하면 서버 인증 오류가 발생합니다.

"Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature".

내가 직접 로컬 서버에 업로드 파일에 대한 SAS 키를 생성 할 수있어
public async void ConfigureCors() { 
     ServiceProperties serviceProperties = await this.blobClient.GetServicePropertiesAsync(); 

     serviceProperties.Cors = new CorsProperties(); 
     serviceProperties.Cors.CorsRules.Clear(); 
     serviceProperties.Cors.CorsRules.Add(new CorsRule() { 
      AllowedHeaders = allowedCorsHeaders, 
      ExposedHeaders = allowedCorsExposedHeaders, 
      AllowedOrigins = allowedCorsOrigin, 
      AllowedMethods = allowedCorsMethods, 
      MaxAgeInSeconds = allowedCorsAgeInSeconds 
     }); 
     await blobClient.SetServicePropertiesAsync(serviceProperties); 
    } 

,하지만 수 없습니다 C# 코드를 통해 저장소에 액세스 할 수 있도록 CORS를 동적으로 구성합니다.

Azure Storage Cloud를 사용할 때 위 코드가 완벽하게 작동하지만 로컬 에뮬레이터에서이 오류가 발생합니다.

버전 정보 :

WindowsAzure.Storage 버전은 8.4.0

윈도우 Azure 스토리지 에뮬레이터 버전 5.2.0.0

푸른 저장 탐색기 버전이 0.9.01

입니다 연결에 사용 된 인증서 :

AccountName = devstoreaccount1;

AccountKey = Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuF q2UVErCz4I6tq/K1SZFP TOtr/KBHBeksoGMGw ==;

답변

0

설명에 따르면, 나는 나의 편에서 시험 데모를 만들었습니다. 잘 작동한다.

Server failed to authenticate the request 오류가 발생하는 이유는 잘못된 저장 용량 패키지 버전과 저장 장치 에뮬레이터 버전입니다.

스토리지 버전을 8.4.0으로, 스토리지 에뮬레이터 버전을 5.2로 먼저 업데이트하고 다시 시도하십시오. 내 테스트 데모에 대한

자세한 내용, 당신은 코드 아래를 참조 수 :

 CloudStorageAccount storageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true"); 

     CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); 



     ServiceProperties serviceProperties = blobClient.GetServicePropertiesAsync().Result; 

     serviceProperties.Cors = new CorsProperties(); 
     serviceProperties.Cors.CorsRules.Clear(); 
     serviceProperties.Cors.CorsRules.Add(new CorsRule() 
     { 
      AllowedHeaders = new List<string>() { "*" }, 
      ExposedHeaders = new List<string>() { "*" }, 
      AllowedOrigins = new List<string>() { "*" }, 
      AllowedMethods = CorsHttpMethods.Put | CorsHttpMethods.Get | CorsHttpMethods.Head | CorsHttpMethods.Post, 
      MaxAgeInSeconds = 1800 
     }); 
     var re = blobClient.SetServicePropertiesAsync(serviceProperties); 

결과 :

enter image description here

+0

WindowsAzure.Storage 버전 8.4.0 윈도우 Azure 스토리지 에뮬레이터 버전 5.2 .0.0 및 Azure 저장소 탐색기 버전은 0.9.01입니다. –

+0

연결에 사용되는 자격 증명 : AccountName = devstoreaccount1; AccountKey = Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UverCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw ==; –

관련 문제