Couchbase error opening bucket - Could not bootstrap - c#

I am trying to connect to my couchbase server (Enterprise ver 4.6.2) and open a bucket using the .Net SDK, the code is very simple but still fail to work:
var cluster = new Cluster(new ClientConfiguration
{
Servers = new List<Uri> { new Uri("https://10.0.0.54:8091/") }
});
try
{
var bucket = cluster.OpenBucket("default");
}
catch (Exception ex)
{
Console.WriteLine("Error getting bucket.");
Console.WriteLine(ex.Message);
}
The inner exception details I get:
Message
Object reference not set to an instance of an object
StackTrace
Couchbase.IO.Services.PooledIOService.CheckEnabledServerFeatures(IConnection connection)
at Couchbase.IO.Services.PooledIOService..ctor(IConnectionPool connectionPool)
at Couchbase.IO.IOServiceFactory.<>c__DisplayClass0_0.<GetFactory>b__0(IConnectionPool pool)
at Couchbase.Configuration.Server.Providers.CarrierPublication.CarrierPublicationProvider.GetConfig(String bucketName, String username, String password)
The main exception I see is:
Could not bootstrap - check inner exceptions for details.
And the stack trace:
at Couchbase.Core.ClusterController.CreateBucket(String bucketName, String username, String password, IAuthenticator authenticator)
at Couchbase.Core.ClusterController.CreateBucket(String bucketName, IAuthenticator authenticator)
at Couchbase.Cluster.OpenBucket(String bucketname)
at Couchbase.Program.Main(String[] args)
Any idea what the issue is?

I had the same problem with the Community edition. In my case I had not created the default bucket before trying to access it. Also, if your server/cluster or bucket require credentials you need to enter those as well.

Expose all required ports
docker run -d -p 8091-8096:8091-8096 -p 11210:11210 -p 11211:11211 couchbase

Related

Smart home report state SYNC new device | Requested entity was not found. [404]

I've implemented the HomeGraph API with the help of the package Google.Apis.HomeGraphService.v1 (1.50.0.2260)
It seems to work fine as well, the ReportStateAndNotification function works fine on the query, execute, and some sync requests.
But when I add a new device to my system through our app and a SYNC request is sent to Google and comes in our backend, the HomeGraph API will return an exception when sending this sync request..
-> The sync request does not throw an exception when I modify a device name in our app. It only occurs when new devices are added.
I've searched through google and multiple StackOverflow posts.. But I'm probably missing something. Most posts say check the API key etc but then the ReportStateAndNotification function should always fail, not only when the sync request comes from Google to our backend.
Could anyone point me in the right direction?
Function that is used for sync requests:
public static void Send(Dictionary<string, object> deviceStateList, string requestId, string googleCustomerId)
{
string deviceIdList = String.Format("({0})", string.Join(", ", deviceStateList.Keys));
try
{
var jsonFilePath = _appSettingsRetriever.PrivateGoogleAuthenticationFile;
string scope = "https://www.googleapis.com/auth/homegraph";
using (var stream = new FileStream(jsonFilePath, FileMode.Open, FileAccess.Read))
{
GoogleCredential credentials = GoogleCredential.FromStream(stream);
if (credentials.IsCreateScopedRequired)
credentials = credentials.CreateScoped(scope);
HomeGraphServiceService service = new HomeGraphServiceService(new BaseClientService.Initializer()
{
HttpClientInitializer = credentials
});
var request = new ReportStateAndNotificationRequest
{
AgentUserId = googleCustomerId,
RequestId = requestId,
Payload = new StateAndNotificationPayload
{
Devices = new ReportStateAndNotificationDevice
{
States = deviceStateList
}
}
};
_log.Debug($"Sending to HomeGraph for devices: {deviceIdList} customer: {googleCustomerId} requestId: {requestId}");
DevicesResource.ReportStateAndNotificationRequest rp = service.Devices.ReportStateAndNotification(request);
ReportStateAndNotificationResponse resop = rp.Execute();
}
}
catch (Exception ex)
{
_log.Error($"Exception in ReportToHomeGraph for Customer: {googleCustomerId}. DeviceList: {deviceIdList}. JsonPath: {_appSettingsRetriever.PrivateGoogleAuthenticationFile} Exception: {ex}.");
}
}
Exception:
2021-09-24 14:16:13,547 [110] ERROR ReportToHomeGraph
Exception in ReportToHomeGraph for Customer: 05. DeviceList: (
fe965e6a-21ad-425f-b594-914bf63510a9,
1cc0ee97-a87f-44c5-a3e3-a39d159ee193,
618cdf94-2b31-434f-b91e-00837d155d4a
).
JsonPath: C:/myfile.json Exception: The service homegraph has thrown an exception:
Google.GoogleApiException: Google.Apis.Requests.RequestError
Requested entity was not found. [404]
Errors [
Message[Requested entity was not found.] Location[ - ] Reason[notFound] Domain[global]
]
at Google.Apis.Requests.ClientServiceRequest`1.<ParseResponse>d__35.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Google.Apis.Requests.ClientServiceRequest`1.Execute()
at BusinessLogic.GoogleAssistant.TokenService.HomeGraph.ReportToHomeGraph.Send(Dictionary`2 deviceStateList,
String requestId, String googleCustomerId) in C:\Repos\GoogleAssistant
.TokenService\HomeGraph\ReportToHomeGraph.cs:line 57.
When users add a new device, the first step you need to do is to issue a Request Sync to Google. This indicates the set of devices for that user has changed, and you need a new Sync request to update the data in homegraph. Google will follow this by delivering a Sync intent to your fulfillment endpoint, which you can respond with the updated set of devices.
Getting a 404 when calling Request Sync might indicate your Service Account Key might be invalid, or the agent user id you target might be wrong. Otherwise getting an error for your Sync Response might indicate it’s structured incorrectly. You can find out more about how to structure it in our examples.

Unknown command FEAT when accessing FTP server

I just created an FTP server based on the code provided here http://www.codeguru.com/csharp/csharp/cs_network/sockets/article.php/c7409/A-C-FTP-Server.htm . Then I installed Nuget packages for FtpClient, so that I can create a test FTP client which connects to FTP server. Following is my code:
[TestMethod]
async public Task TestMethod1() // wanted to make it async as I may connect have something related to database in future
{
var client = new FtpClient
{
Host = "127.0.0.1",
Port = 21,
Credentials = new NetworkCredential
{
UserName = "123",
Password = "123",
},
DataConnectionType = FtpDataConnectionType.PASV // If I don't add this, I get EPSV unknown command
};
await client.ConnectAsync();
Debug.WriteLine("Connected");
client.SetWorkingDirectory(#"C:\Users\myname\Desktop");
Debug.WriteLine(client.GetWorkingDirectory());
try
{
var items = client.GetListing(); // Exception shows up here.
Debug.WriteLine(items.Count());
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
The issue could be that I don't have a command handler for FEAT in my server. But, my FTP server runs completely fine with filezilla. If command handler is required, can someone provide me code for this?
If I ignore this error, I get this exception in test method "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."
Any ideas?
[EDIT]
Here's the full exception:
Test method Blackhawk.Core.FtpServer.Test.UnitTest1.TestMethod1 threw exception:
System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
at System.Net.FtpClient.FtpSocketStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.FtpClient.FtpSocketStream.ReadLine(Encoding encoding)
at System.Net.FtpClient.FtpClient.GetReply()
at System.Net.FtpClient.FtpClient.Execute(String command)
at System.Net.FtpClient.FtpClient.OpenPassiveDataStream(FtpDataConnectionType type, String command, Int64 restart)
at System.Net.FtpClient.FtpClient.OpenDataStream(String command, Int64 restart)
at System.Net.FtpClient.FtpClient.GetListing(String path, FtpListOption options)
at System.Net.FtpClient.FtpClient.GetListing(String path)
at Blackhawk.Core.FtpServer.Test.UnitTest1.<TestMethod1>d__2.MoveNext() in UnitTest1.cs: line 44
--- 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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
I was able to solve the problem by changing data connection type to AutoActive. Here's the final code which works:
[TestMethod]
async public Task FtpTestUser1()
{
var client = new FtpClient
{
Host = "127.0.0.1",
Port = 21,
Encoding = System.Text.Encoding.Default,
Credentials = new NetworkCredential
{
// Storing username, password and default directory in a .dat file
UserName = "123",
Password = "123",
},
DataConnectionType = FtpDataConnectionType.AutoActive // Changed this part.
};
await client.ConnectAsync();
Debug.WriteLine("Connected");
var path = #"Test"; // This path is now relative to the default directory
client.SetWorkingDirectory(path);
Debug.WriteLine(client.GetWorkingDirectory());
var items = client.GetListing();
Assert.IsTrue(items.Any());
Debug.WriteLine(items.Count());
foreach (var ftpListItem in items)
{
Debug.WriteLine(string.Format("File name is {0}", ftpListItem.Name));
}
}

No message or timeout when trying to connect to sftp server

I'm trying to connect to a sftp server and I don't get any exception or timeout, only increasing memory usage.
I am using the library EnterpriseDT.Net.Ftp
My code is like this:
XmlConfigurator.Configure();
Module1.Logger = LogManager.GetLogger("SftpTester");
try
{
Module1.Logger.Info((object) "[EnterpriseDT] - Start");
Uri uri1 = new Uri("ftp://*****");
// ISSUE: explicit reference operation
// ISSUE: variable of a reference type
Uri& uri2 = #uri1;
int port = ****;
string str1 = "******";
// ISSUE: explicit reference operation
// ISSUE: variable of a reference type
string& UserName = #str1;
string str2 = "*******";
// ISSUE: explicit reference operation
// ISSUE: variable of a reference type
string& Password = #str2;
SecureFTPConnection secureFtpConnection = Module1.InitConnection(uri2, port, UserName, Password);
Module1.Logger.Info((object) "Connecting to ftp...");
secureFtpConnection.Connect();
Module1.Logger.Info((object) "Connection Successful!!!");
try
{
Module1.Logger.Info((object) "Disposing connection...");
secureFtpConnection.Dispose();
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
ProjectData.ClearProjectError();
}
Module1.Logger.Info((object) "Connection Disposed.");
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
Exception exception = ex;
Module1.Logger.Error((object) ("Main() - " + exception.Message));
Module1.Logger.Error((object) ("StackTrace: " + exception.StackTrace));
if (exception.InnerException != null)
Module1.Logger.Error((object) ("InnerException: " + exception.InnerException.Message));
ProjectData.ClearProjectError();
}
finally
{
Module1.Logger.Info((object) "[EnterpriseDT] - End");
}
private static SecureFTPConnection InitConnection(ref Uri uri, int port, ref string UserName = "", ref string Password = "")
{
Module1.Logger.Info((object) "InitConnection() - Setting Up Connection");
SecureFTPConnection secureFtpConnection = new SecureFTPConnection();
secureFtpConnection.LicenseOwner = "*******";
secureFtpConnection.LicenseKey = "***********";
secureFtpConnection.ServerAddress = uri.Host;
Module1.Logger.Info((object) ("\tHost: " + uri.Host));
secureFtpConnection.UserName = UserName;
Module1.Logger.Info((object) ("\tUsername: " + UserName));
secureFtpConnection.Protocol = FileTransferProtocol.SFTP;
Module1.Logger.Info((object) ("\tProtocol: " + FileTransferProtocol.SFTP.ToString()));
secureFtpConnection.ServerValidation = SecureFTPServerValidationType.None;
Module1.Logger.Info((object) ("\tServerValidation: " + SecureFTPServerValidationType.None.ToString()));
secureFtpConnection.AuthenticationMethod = AuthenticationType.Password;
Module1.Logger.Info((object) ("\tAuthenticationMethod: " + AuthenticationType.Password.ToString()));
if (port > 0)
{
secureFtpConnection.ServerPort = port;
Module1.Logger.Info((object) ("\tServerPort: " + port.ToString()));
}
secureFtpConnection.Password = Password;
Module1.Logger.Info((object) ("\tPassword: " + Password));
return secureFtpConnection;
}
Log message:
2014-09-27 04:50:22,783 [1] - [SftpTester] [EnterpriseDT] - Start
2014-09-27 04:50:22,799 [1] - [SftpTester] InitConnection() - Setting Up Connection
2014-09-27 04:50:22,971 [1] - [SftpTester] Host: *******
2014-09-27 04:50:22,971 [1] - [SftpTester] Username: *****
2014-09-27 04:50:22,971 [1] - [SftpTester] Protocol: SFTP
2014-09-27 04:50:22,971 [1] - [SftpTester] ServerValidation: None
2014-09-27 04:50:22,971 [1] - [SftpTester] AuthenticationMethod: Password
2014-09-27 04:50:22,971 [1] - [SftpTester] ServerPort: ****
2014-09-27 04:50:22,971 [1] - [SftpTester] Password: ******
2014-09-27 04:50:22,971 [1] - [SftpTester] Connecting to ftp...
Any idea if this is a timeout error or if I am in a blacklist?
Update 07/10/2014
Sequence for server:
Password authentication
Waiting for packet
Packet arrived
Auth partial success. Try: password, publickey, keyboard-interactive
Keyboard interactive authentication
Waiting for packet
Packet arrived
Prompt: Password:
Waiting for packet
Packet arrived
Auth partial success. Try: password, publickey, keyboard-interactive
Waiting for packet
Packet arrived
Prompt: Password:
Loop (9 to 15)
update
Updating the library solve the problem, was a bug.
Version 8.6.1
(23 Sep 2014)
Fixed kbi re-entrant bug that causes a loop of authentication attempts.
Fixed SFTP bug where an exception wasn't thrown when uploading a file to a non-existent directory.
Fixed SFTP problem where an OpenVMS SFTP server wasn't being recognized as SSH.
Fixed retry download problem where only one reconnect was made.
Fixed "Attempted to read or write protected memory" issue on some 2012 R2 machines using FTPS.
Your code looks ok. There is nothing special about it. The first thing you should do is enable Debug logging in the library, since you don't have enough information about the execution of your FTP code.
You can enable Debug with the following statement:
EnterpriseDT.Util.Debug.Logger.CurrentLevel = EnterpriseDT.Util.Debug.Level.DEBUG;
By default it will print debug info in the Console. you can use a custom appender (file, db etc.) if you like. The Debug info will give you much more information about the issue.
Any idea about if is a timeout error?
I don't think so. There is a client timeout set to 120000ms in the library by default. The Server timeouts are probably much higher. I don't think it is a timeout issue.
Am in a blacklist?
Maybe, but again that shouldn't hang an FTP client.
Why there is No message or timeout then?
Hangs could be caused by improper FTP Server or Firewall config. EnterpriseDT.Net.Ftp uses FTP Passive mode by default like most FTP clients. I would suggest checking your FTP server and firewall configuration and check everything is configured properly for Passive mode.
If your FTP Server is configured properly, you should be able to connect to it from any FTP client. You can try FileZilla or any other client, just to make sure your server is setup correctly. That way you will rule out any firewall or FTP server issues.
Update:
From what we see so far in the log it is an Auth issue. Looks like the SSH server supports password, publickey and keyboard-interactive auth.
My interpretation of your log above is that your SFTP client is trying to authenticate with the following methods in this exact order:
Try: password, publickey, keyboard-interactive
Password authentication (the default in your code) doesn't go through (wrong password?) and then the client switches to Keyboard authentication and that's why you are getting a password prompt in SSH, and the SFTP library is not able to handle that scenario, since you are not including a prompt response.
To fix that you should check out the SSHAuthPrompt class in the library, and include the prompt answer with the password in your code using the KBIPrompts property on the SecureFTPConnection class:
http://www.enterprisedt.com/products/edtftpnetpro/doc/manual/api/html/T_EnterpriseDT_Net_Ftp_Ssh_SSHAuthPrompt.htm
This class has two params in the constructor. The prompt should match what you are getting from KBI, and that should be 'Password:', the response value should be the password.
You should also try configuring the AuthenticationMode to KeyboardInteractive.

Amazon AWS: Failing to Login

I've been working on an amazon EC2 project and when I login like this:
public bool Login(Credentials credentials, string ownerID, string region)
{
try
{
OwnerID = ownerID;
CurrentCredentials = credentials;
CurrentConfigs = new AmazonEC2Config() { RegionEndpoint = RegionEndpoint.GetBySystemName(region) };
EC2 = AWSClientFactory.CreateAmazonEC2Client(CurrentCredentials, CurrentConfigs);
}
catch
{
return false;
}
return true;
}
And then try to access like this:
DescribeInstancesRequest ec2Request = new DescribeInstancesRequest();
ec2Request.InstanceIds = new List<string>() { id };
DescribeInstancesResponse ec2Response = EC2.DescribeInstances(ec2Request);
return ec2Response.Reservations[0].Instances[0];
I get this exception:
EXCEPTION:
Encountered a WebException (NameResolutionFailure), the request cannot be retried. Either the maximum number of retries has been exceeded (4/4) or the request is using a non-seekable stream.
STACK TRACE:
at Amazon.Runtime.AmazonWebServiceClient.HandleHttpWebErrorResponse(AsyncResult asyncResult, WebException we)
at Amazon.Runtime.AmazonWebServiceClient.getRequestStreamCallback(IAsyncResult result)
at Amazon.Runtime.AmazonWebServiceClient.endOperation[T](IAsyncResult result)
at Amazon.EC2.AmazonEC2Client.DescribeInstances(DescribeInstancesRequest describeInstancesRequest)
at ...
EDIT:
This exception's inner exception is:
The remote name could not be resolved: 'ec2.sa-east-1a.amazonaws.com'
It's important to point out that it only gives me this error when the access is to region sa-east-1a. Another account I have in region us-west-2 works perfectly. Also, I have extracted the Credential and Region information from the web.config
Simple error, simple solution: The region is sa-east-1 not sa-east-1a. When logging in, you shouldn't specify which datacenter to use, just the region.
As an appendix to this, to anyone arriving here who wasn't specifying the datacenter. In my case using RegionEndpoint.GetBySystemName("USEast1") vs RegionEndpoint.GetBySystemName("US-East-1") was the difference maker.

Cannot upload to azure Blob Storage: The remote server returned an error: (400) Bad Request

I'm trying to create a utility to download file from the internet and upload it again to Azure blob storage.
Blob containers already created well; But for some reason i'm getting "Bad Request 400" exception when i tried to upload the file to storage ... Container name is created, small letters, so special characters. But I still do not know why i'm getting the exception!
Please help.
Note:
I'm not using any emulator ... Directly testing on the cloud.
All of my containers with "Public Container" access option.
Here is the exception:
An exception of type 'Microsoft.WindowsAzure.Storage.StorageException'
occurred in Microsoft.WindowsAzure.Storage.dll but was not handled in user code
Additional information: The remote server returned an error: (400) Bad Request.
And here is the code:
foreach (var obj in objectsList)
{
var containerName = obj.id.Replace("\"", "").Replace("_", "").Trim();
CloudBlobContainer blobContainer = blobClient.GetContainerReference(containerName);
if (blobContainer.Exists())
{
var fileNamesArr = obj.fileNames.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var sora in fileNamesArr)
{
int soraInt = int.Parse(sora.Replace("\"", ""));
String fileName = String.Format("{0}.mp3", soraInt.ToString("000"));
var url = String.Format("http://{0}/{1}/{2}", obj.hostName.Replace("\"", ""), obj.id.Replace("\"", ""), fileName.Replace("\"", "")).ToLower();
var tempFileName = "temp.mp3";
var downloadedFilePath = Path.Combine(Path.GetTempPath(), tempFileName).ToLower();
var webUtil = new WebUtils(url);
await webUtil.DownloadAsync(url, downloadedFilePath).ContinueWith(task =>
{
var blobRef = blobContainer.GetBlockBlobReference(fileName.ToLower());
blobRef.Properties.ContentType = GetMimeType(downloadedFilePath);
using (var fs = new FileStream(downloadedFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
blobRef.UploadFromStream(fs); // <--- Exception
}
});
}
}
else
{
throw new Exception(obj.id.Replace("\"", "") + " Container not exist!");
}
}
Edit: The Storage Exception
Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand1 cmd, IRetryPolicy policy, OperationContext operationContext)
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand1 cmd, IRetryPolicy policy, OperationContext operationContext)
at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.UploadFromStreamHelper(Stream source, Nullable`1 length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.UploadFromStream(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
at TelawatAzureUtility.StorageService.<>c__DisplayClass4.b__12(Task task) in \psf\Home\Documents\Visual Studio 14\Projects\Telawat Azure Utility\TelawatAzureUtility\StorageService.cs:line 128
Request Information
RequestID:
RequestDate:Sat, 28 Jun 2014 20:12:14 GMT
StatusMessage:Bad Request
Edit 2: Request Information:
Edit 3: The problem comes from WebUtils .. I replaced it with below code and it works! I will add weUtils code, maybe you can help to know what is the problem with it.
HttpClient client = new HttpClient();
var stream = await client.GetStreamAsync(url);
WebUtils Code:
public class WebUtils
{
private Lazy<IWebProxy> proxy;
public WebUtils(String url)
{
proxy = new Lazy<IWebProxy>(() => string.IsNullOrEmpty(url) ? null : new WebProxy {
Address = new Uri(url), UseDefaultCredentials = true });
}
public IWebProxy Proxy
{
get { return proxy.Value; }
}
public Task DownloadAsync(string requestUri, string filename)
{
if (requestUri == null)
throw new ArgumentNullException("requestUri is missing!");
return DownloadAsync(new Uri(requestUri), filename);
}
public async Task DownloadAsync(Uri requestUri, string filename)
{
if (filename == null)
throw new ArgumentNullException("filename is missing!");
if (Proxy != null)
{
WebRequest.DefaultWebProxy = Proxy;
}
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(HttpMethod.Get, requestUri))
{
using (Stream contentStream = await (await httpClient.SendAsync(request)).Content.ReadAsStreamAsync())
{
using (var stream = new FileStream(filename, FileMode.Create, FileAccess.Write))
{
contentStream.CopyTo(stream);
stream.Flush();
stream.Close();
}
contentStream.Close();
}
}
}
}
}
Also when I tried this code ... the 'Wait' will never finish or completed!
webUtil.DownloadAsync(url, downloadedFilePath).Wait()
Have you tried creating a container manually on azure portal? It has some limitations on what name you can give containers.
For example: Container name cannot contain upper case letters.
If you request a container with an invalid name, it will result in (400) Bad Request, which you are getting. So check your "containerName" string.
I had the same problem. I resolved it by changing the TLS version in the configuration of the storage; the new TLS version (1.2) is not compatible with the older version of the storage client. I changed it to the 1.0 and it works.
The configuration of the storage is in the portal of Azure.
Storage -> Configuration -> TLS Version:
I also got this error with the Azure Storage Message Queues.
The Azure Storage Message Queue names must also be all lowercase.
ie: "newqueueitem" name in lowercase.
// Retrieve a reference to a queue.
CloudQueue queue = queueClient.GetQueueReference("newqueueitem");
// Create the queue if it doesn't already exist.
queue.CreateIfNotExists();
If you create a container with an invalid name, it will result in (400) Bad Request. There are some convention for creating container name as below:
Container names must start with a letter or number, and can contain only letters, numbers, and the dash (-) character.
Every dash (-) character must be immediately preceded and followed by a letter or number; consecutive dashes are not permitted in
container names.
All letters in a container name must be lowercase.
Container names must be from 3 through 63 characters long.
Source: https://learn.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata
I had a very different case of bad request message. Posting here for anyone else who may hit the same. In my case, I was just moving around resource across other resource groups . In that shuffling, a bug in azure allowed me to point my storage to location ("South East Asia") which was not available in my region. So all requests against the storage account returned the bad request message. It took me a while to figure this out because I then created another storage account to test, which when creating, azure did not allow me to pick "South East Asia" as a location of choice, so I picked another location ("East Asia") and then everything worked fine.
I know it's been a long time but I was able to fix it for TLS 1.2 with the following line of code:
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
It would be something like this :
public async Task DownloadAsync(Uri requestUri, string filename){
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
... your code...
}
I faced the same issue while creating the queue in Azure with one UpperCase Letter from my C# code. The error was with the Queue Name. All the characters should be lowercase. After changing all the characters to lowercase it worked! :)
//Retrieve a reference to a queue
CloudQueue queue = queueClient.GetQueueReference("myqueue");
//Create a queue if it alredy doen't exists
queue.CreateIfNotExists();

Categories