Exemplo n.º 1
0
        static string connectionString = "";  // Example: HostName=PierceHub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=SPHff77vetNDgrZahijsTMhGqZd0MllkgG0JyLzfz2E=

        public static void Main(string[] args)
        {
            Console.WriteLine("Device Provisioning Tool");
            Console.WriteLine("Creating a unique device identity for device: coffeeMaker");
            registryManager = RegistryManager.CreateFromConnectionString(connectionString);
            AddDeviceAsync().Wait();
            Console.WriteLine("Creating a unique Shared Access Signature for your account:");

            var signature = new SharedAccessSignatureBuilder()
            {
                KeyName    = policyName,
                Key        = policyKey,
                Target     = iotHubUrl,
                TimeToLive = TimeSpan.FromDays(365)
            }.ToSignature();

            Console.WriteLine(signature);
            Console.ReadLine();
        }
Exemplo n.º 2
0
		static string connectionString = ""; // Example: HostName=PierceHub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=SPHff77vetNDgrZahijsTMhGqZd0MllkgG0JyLzfz2E=

		public static void Main(string[] args)
		{
			Console.WriteLine("Device Provisioning Tool");
			Console.WriteLine("Creating a unique device identity for device: coffeeMaker");
			registryManager = RegistryManager.CreateFromConnectionString(connectionString);
			AddDeviceAsync().Wait();
			Console.WriteLine("Creating a unique Shared Access Signature for your account:");

			var signature = new SharedAccessSignatureBuilder()
			{
				KeyName = policyName,
				Key = policyKey,
				Target = iotHubUrl,
				TimeToLive = TimeSpan.FromDays(365)
			}.ToSignature();

			Console.WriteLine(signature);
			Console.ReadLine();
		}