Ich versuche, neue Ordner in meinem datalake store
zu erstellen, gibt es keinen Fehler im Code, aber nichts wird in datalake store
widergespiegelt.Azure Data Lake Store erstellen Ordner über C# -Skript
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Threading;
using Microsoft.Azure.Management.DataLake.Store;
using Microsoft.Azure.Management.DataLake.Store.Models;
using Microsoft.Rest.Azure.Authentication;
namespace test_dlstore
{
class Program
{
private static DataLakeStoreAccountManagementClient _adlsClient;
private static DataLakeStoreFileSystemManagementClient _adlsFileSystemClient;
private static string _adlsAccountName;
private static string _subId;
private static void Main(string[] args)
{
_adlsAccountName = "[email protected]";
_subId = "2342342-97ce-a54b2-ba6e-234234234234234";
string localFolderPath = @"C:\myfolder\"; // TODO: Make sure this exists and can be overwritten.
string localFilePath = Path.Combine(localFolderPath, "try.txt");
string remoteFolderPath = "adl://mystore.azuredatalakestore.net/myfolder";
string remoteFilePath = Path.Combine(remoteFolderPath, "try.txt");
SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
var tenant_id = "my-tenant-id";
var nativeClientApp_clientId = "1950a258-227b-4e31-a9cf-717495945fc2";
var activeDirectoryClientSettings = ActiveDirectoryClientSettings.UsePromptOnly(nativeClientApp_clientId, new Uri("urn:ietf:wg:oauth:2.0:oob"));
var creds = UserTokenProvider.LoginWithPromptAsync(tenant_id, activeDirectoryClientSettings).Result;
_adlsClient = new DataLakeStoreAccountManagementClient(creds) { SubscriptionId = _subId };
_adlsFileSystemClient = new DataLakeStoreFileSystemManagementClient(creds);
Console.WriteLine(ListAdlStoreAccounts());
Console.WriteLine(AppendToFile("adl://mystore.azuredatalakestore.net/myfolder/stage/testfile.txt", "abcdefghijklmnopqrstuvwxyz"));
CreateDirectory("adl://mystore.azuredatalakestore.net/myfolder/newdir");
Console.ReadLine();
}
// Append to file
public static string AppendToFile(string path, string content)
{
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(content)))
{
Console.WriteLine(_adlsAccountName, path, content);
Console.WriteLine(path);
Console.WriteLine(content);
_adlsFileSystemClient.FileSystem.AppendAsync(_adlsAccountName, path, stream);
return "Tried";
}
}
public static string CreateDirectory(string path)
{
_adlsFileSystemClient.FileSystem.MkdirsAsync(_adlsAccountName, path);
return "Tried Creating directory.";
}
}
}
Nach der Ausführung des oben genannten Code verlässt Programm ohne Fehler. Die Verbindung wird hergestellt.
Auch es zeigt datalake
Geschäfte, die vorhanden sind, aber nicht in der Lage, etwas über die Data Lake Geschäfte zu tun.
Ich bin neu in Azure bitte hilf mir.
Wenn Sie nur Ordner erstellen versuchen, bitte versuchen '_adlsFileSystemClient.FileSystem.Mkdirs zu verwenden (_adlsAccountName "/ folder")'; –
@ TomSun-MSFT versuchte es. aber ** keine Änderungen ** in meinem Datalake Store. – Shubham
Bitte versuchen Sie es einfach mit dem Code, den ich erwähnt habe, ohne anderen Code. Bitte verwenden Sie relativen Pfad nicht vollständigen Pfad. Ich habe es auf meiner Seite getestet, es funktioniert einwandfrei. –