Skip to content

Commit 860aae5

Browse files
authored
Merge pull request #50059 from robinsh/robinsh-set5-pics
Fix pics for set5 and set6, set6 changes.
2 parents 467a679 + b0fea9f commit 860aae5

File tree

46 files changed

+461
-498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+461
-498
lines changed

articles/iot-hub/iot-hub-csharp-csharp-device-management-get-started.md

Lines changed: 132 additions & 119 deletions
Large diffs are not rendered by default.

articles/iot-hub/iot-hub-csharp-csharp-file-upload.md

Lines changed: 25 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Upload files from devices to Azure IoT Hub with .NET | Microsoft Docs
33
description: How to upload files from a device to the cloud using Azure IoT device SDK for .NET. Uploaded files are stored in an Azure storage blob container.
44
author: fsautomata
5-
manager:
65
ms.service: iot-hub
76
services: iot-hub
87
ms.devlang: csharp
@@ -18,9 +17,10 @@ ms.author: elioda
1817
This tutorial builds on the code in the [Send Cloud-to-Device messages with IoT Hub](iot-hub-csharp-csharp-c2d.md) tutorial to show you how to use the file upload capabilities of IoT Hub. It shows you how to:
1918

2019
- Securely provide a device with an Azure blob URI for uploading a file.
20+
2121
- Use the IoT Hub file upload notifications to trigger processing the file in your app back end.
2222

23-
The [Get started with IoT Hub](quickstart-send-telemetry-dotnet.md) and [Send Cloud-to-Device messages with IoT Hub](iot-hub-csharp-csharp-c2d.md) tutorials show the basic device-to-cloud and cloud-to-device messaging functionality of IoT Hub. The [Process Device-to-Cloud messages](tutorial-routing.md) tutorial describes a way to reliably store device-to-cloud messages in Azure blob storage. However, in some scenarios you cannot easily map the data your devices send into the relatively small device-to-cloud messages that IoT Hub accepts. For example:
23+
The [Send telemetry from a device to an IoT hub](quickstart-send-telemetry-dotnet.md) and [Send Cloud-to-Device messages with IoT Hub](iot-hub-csharp-csharp-c2d.md) articles show the basic device-to-cloud and cloud-to-device messaging functionality of IoT Hub. The [Configure Message Routing with IoT Hub](tutorial-routing.md) tutorial describes a way to reliably store device-to-cloud messages in Azure blob storage. However, in some scenarios you cannot easily map the data your devices send into the relatively small device-to-cloud messages that IoT Hub accepts. For example:
2424

2525
* Large files that contain images
2626
* Videos
@@ -32,15 +32,16 @@ These files are typically batch processed in the cloud using tools such as [Azur
3232
At the end of this tutorial you run two .NET console apps:
3333

3434
* **SimulatedDevice**, a modified version of the app created in the [Send Cloud-to-Device messages with IoT Hub](iot-hub-csharp-csharp-c2d.md) tutorial. This app uploads a file to storage using a SAS URI provided by your IoT hub.
35+
3536
* **ReadFileUploadNotification**, which receives file upload notifications from your IoT hub.
3637

3738
> [!NOTE]
38-
> IoT Hub supports many device platforms and languages (including C, Java, and Javascript) through Azure IoT device SDKs. Refer to the [Azure IoT Developer Center] for step-by-step instructions on how to connect your device to Azure IoT Hub.
39+
> IoT Hub supports many device platforms and languages (including C, Java, and Javascript) through Azure IoT device SDKs. Refer to the [Azure IoT Developer Center](http://azure.microsoft.com/develop/iot) for step-by-step instructions on how to connect your device to Azure IoT Hub.
3940
4041
To complete this tutorial, you need the following:
4142

42-
* Visual Studio 2015 or Visual Studio 2017
43-
* An active Azure account. (If you don't have an account, you can create a [free account][lnk-free-trial] in just a couple of minutes.)
43+
* Visual Studio 2017
44+
* An active Azure account. (If you don't have an account, you can create a [free account](http://azure.microsoft.com/pricing/free-trial/) in just a couple of minutes.)
4445

4546
[!INCLUDE [iot-hub-associate-storage](../../includes/iot-hub-associate-storage.md)]
4647

@@ -52,7 +53,7 @@ In this section, you modify the device app you created in [Send Cloud-to-Device
5253

5354
1. Right-click on the image, and then click **Properties**. Make sure that **Copy to Output Directory** is set to **Copy always**.
5455

55-
![][1]
56+
![Show where to update the image property for Copy to Output Directory](./media/iot-hub-csharp-csharp-file-upload/image-properties.png)
5657

5758
1. In the **Program.cs** file, add the following statements at the top of the file:
5859

@@ -88,36 +89,36 @@ In this section, you modify the device app you created in [Send Cloud-to-Device
8889
```
8990

9091
> [!NOTE]
91-
> For simplicity's sake, this tutorial does not implement any retry policy. In production code, you should implement retry policies (such as exponential backoff), as suggested in the MSDN article [Transient Fault Handling].
92+
> For simplicity's sake, this tutorial does not implement any retry policy. In production code, you should implement retry policies (such as exponential backoff), as suggested in the MSDN article [Transient Fault Handling](https://msdn.microsoft.com/library/hh680901.aspx).
9293

9394
## Receive a file upload notification
9495

9596
In this section, you write a .NET console app that receives file upload notification messages from IoT Hub.
9697

9798
1. In the current Visual Studio solution, create a Visual C# Windows project by using the **Console Application** project template. Name the project **ReadFileUploadNotification**.
9899

99-
![New project in Visual Studio][2]
100+
![New project in Visual Studio](./media/iot-hub-csharp-csharp-file-upload/file-upload-project-csharp1.png)
100101

101-
1. In Solution Explorer, right-click the **ReadFileUploadNotification** project, and then click **Manage NuGet Packages...**.
102+
2. In Solution Explorer, right-click the **ReadFileUploadNotification** project, and then click **Manage NuGet Packages...**.
102103

103-
1. In the **NuGet Package Manager** window, search for **Microsoft.Azure.Devices**, click **Install**, and accept the terms of use.
104+
3. In the **NuGet Package Manager** window, search for **Microsoft.Azure.Devices**, click **Install**, and accept the terms of use.
104105

105-
This action downloads, installs, and adds a reference to the [Azure IoT service SDK NuGet package] in the **ReadFileUploadNotification** project.
106+
This action downloads, installs, and adds a reference to the [Azure IoT service SDK NuGet package](https://www.nuget.org/packages/Microsoft.Azure.Devices/) in the **ReadFileUploadNotification** project.
106107
107-
1. In the **Program.cs** file, add the following statements at the top of the file:
108+
4. In the **Program.cs** file, add the following statements at the top of the file:
108109

109110
```csharp
110111
using Microsoft.Azure.Devices;
111112
```
112113

113-
1. Add the following fields to the **Program** class. Substitute the placeholder value with the IoT hub connection string from [Get started with IoT Hub]:
114+
5. Add the following fields to the **Program** class. Substitute the placeholder value with the IoT hub connection string from [Get started with IoT Hub]:
114115

115116
```csharp
116117
static ServiceClient serviceClient;
117118
static string connectionString = "{iot hub connection string}";
118119
```
119120

120-
1. Add the following method to the **Program** class:
121+
6. Add the following method to the **Program** class:
121122

122123
```csharp
123124
private async static void ReceiveFileUploadNotificationAsync()
@@ -131,17 +132,18 @@ In this section, you write a .NET console app that receives file upload notifica
131132
if (fileUploadNotification == null) continue;
132133

133134
Console.ForegroundColor = ConsoleColor.Yellow;
134-
Console.WriteLine("Received file upload noticiation: {0}", string.Join(", ", fileUploadNotification.BlobName));
135+
Console.WriteLine("Received file upload notification: {0}",
136+
string.Join(", ", fileUploadNotification.BlobName));
135137
Console.ResetColor();
136138

137139
await notificationReceiver.CompleteAsync(fileUploadNotification);
138140
}
139-
}
141+
}
140142
```
141143

142144
Note this receive pattern is the same one used to receive cloud-to-device messages from the device app.
143145

144-
1. Finally, add the following lines to the **Main** method:
146+
7. Finally, add the following lines to the **Main** method:
145147

146148
```csharp
147149
Console.WriteLine("Receive file upload notifications\n");
@@ -157,40 +159,19 @@ Now you are ready to run the applications.
157159

158160
1. In Visual Studio, right-click your solution, and select **Set StartUp projects**. Select **Multiple startup projects**, then select the **Start** action for **ReadFileUploadNotification** and **SimulatedDevice**.
159161

160-
1. Press **F5**. Both applications should start. You should see the upload completed in one console app and the upload notification message received by the other console app. You can use the [Azure portal] or Visual Studio Server Explorer to check for the presence of the uploaded file in your Azure Storage account.
162+
2. Press **F5**. Both applications should start. You should see the upload completed in one console app and the upload notification message received by the other console app. You can use the [Azure portal](https://portal.azure.com/) or Visual Studio Server Explorer to check for the presence of the uploaded file in your Azure Storage account.
161163
162-
![][50]
164+
![Screenshot showing the output screen](./media/iot-hub-csharp-csharp-file-upload/run-apps1.png)
163165

164166
## Next steps
165167

166168
In this tutorial, you learned how to use the file upload capabilities of IoT Hub to simplify file uploads from devices. You can continue to explore IoT hub features and scenarios with the following articles:
167169

168-
* [Create an IoT hub programmatically][lnk-create-hub]
169-
* [Introduction to C SDK][lnk-c-sdk]
170-
* [Azure IoT SDKs][lnk-sdks]
170+
* [Create an IoT hub programmatically](iot-hub-rm-template-powershell.md)
171+
* [Introduction to C SDK](iot-hub-device-sdk-c-intro.md)
172+
* [Azure IoT SDKs](iot-hub-devguide-sdks.md)
171173

172174
To further explore the capabilities of IoT Hub, see:
173175

174-
* [Deploying AI to edge devices with Azure IoT Edge][lnk-iotedge]
175-
176-
<!-- Images. -->
177-
178-
[50]: ./media/iot-hub-csharp-csharp-file-upload/run-apps1.png
179-
[1]: ./media/iot-hub-csharp-csharp-file-upload/image-properties.png
180-
[2]: ./media/iot-hub-csharp-csharp-file-upload/file-upload-project-csharp1.png
181-
182-
<!-- Links -->
183-
184-
[Azure portal]: https://portal.azure.com/
185-
186-
[Azure IoT Developer Center]: http://azure.microsoft.com/develop/iot
187-
188-
[Transient Fault Handling]: https://msdn.microsoft.com/library/hh680901(v=pandp.50).aspx
189-
[Azure IoT service SDK NuGet package]: https://www.nuget.org/packages/Microsoft.Azure.Devices/
190-
[lnk-free-trial]: http://azure.microsoft.com/pricing/free-trial/
191-
192-
[lnk-create-hub]: iot-hub-rm-template-powershell.md
193-
[lnk-c-sdk]: iot-hub-device-sdk-c-intro.md
194-
[lnk-sdks]: iot-hub-devguide-sdks.md
176+
* [Deploying AI to edge devices with Azure IoT Edge](../iot-edge/tutorial-simulate-device-linux.md)
195177

196-
[lnk-iotedge]: ../iot-edge/tutorial-simulate-device-linux.md

articles/iot-hub/iot-hub-csharp-csharp-module-twin-getstarted.md

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Get started with Azure IoT Hub module identity and module twin (.NET) | Microsoft Docs
33
description: Learn how to create module identity and update module twin using IoT SDKs for .NET.
44
author: chrissie926
5-
manager:
65
ms.service: iot-hub
76
services: iot-hub
87
ms.devlang: csharp
@@ -19,15 +18,17 @@ ms.author: menchi
1918
At the end of this tutorial, you have two .NET console apps:
2019

2120
* **CreateIdentities**, which creates a device identity, a module identity and associated security key to connect your device and module clients.
21+
2222
* **UpdateModuleTwinReportedProperties**, which sends updated module twin reported properties to your IoT Hub.
2323

2424
> [!NOTE]
25-
> For information about the Azure IoT SDKs that you can use to build both applications to run on devices, and your solution back end, see [Azure IoT SDKs][lnk-hub-sdks].
25+
> For information about the Azure IoT SDKs that you can use to build both applications to run on devices, and your solution back end, see [Azure IoT SDKs](iot-hub-devguide-sdks.md).
2626
2727
To complete this tutorial, you need the following:
2828

29-
* Visual Studio 2015 or Visual Studio 2017.
30-
* An active Azure account. (If you don't have an account, you can create a [free account][lnk-free-trial] in just a couple of minutes.)
29+
* Visual Studio 2017.
30+
31+
* An active Azure account. (If you don't have an account, you can create a [free account](http://azure.microsoft.com/pricing/free-trial/) in just a couple of minutes.)
3132

3233
[!INCLUDE [iot-hub-get-started-create-hub](../../includes/iot-hub-get-started-create-hub.md)]
3334

@@ -40,20 +41,21 @@ You have now created your IoT hub, and you have the host name and IoT Hub connec
4041

4142
In this section, you create a .NET console app on your simulated device that updates the module twin reported properties.
4243

43-
1. **Create a Visual Studio project** - In Visual Studio, add a Visual C# Windows Classic Desktop project to the existing solution by using the **Console App (.NET Framework)** project template. Make sure the .NET Framework version is 4.6.1 or later. Name the project **UpdateModuleTwinReportedProperties**.
44+
1. **Create a Visual Studio project:** In Visual Studio, add a Visual C# Windows Classic Desktop project to the existing solution by using the **Console App (.NET Framework)** project template. Make sure the .NET Framework version is 4.6.1 or later. Name the project **UpdateModuleTwinReportedProperties**.
4445

45-
![Create a visual studio project][13]
46+
![Create a visual studio project](./media/iot-hub-csharp-csharp-module-twin-getstarted/update-twins-csharp1.JPG)
4647

47-
2. **Install the latest Azure IoT Hub .NET device SDK** - Module identity and module twin is in public preview. It's only availble in the IoT Hub prerelease device SDKs. In Visual Studio, open tools > Nuget package manager > manage Nuget packages for solution. Search Microsoft.Azure.Devices.Client. Make sure you've checked include prerelease check box. Select the latest version and install. Now you have access to all the module features.
48+
2. **Install the latest Azure IoT Hub .NET device SDK:** Module identity and module twin is in public preview. It's only availble in the IoT Hub prerelease device SDKs. In Visual Studio, open tools > Nuget package manager > manage Nuget packages for solution. Search Microsoft.Azure.Devices.Client. Make sure you've checked include prerelease check box. Select the latest version and install. Now you have access to all the module features.
4849

49-
![Install Azure IoT Hub .NET service SDK V1.16.0-preview-005][14]
50+
![Install Azure IoT Hub .NET service SDK V1.16.0-preview-005](./media/iot-hub-csharp-csharp-module-twin-getstarted/install-sdk.png)
5051

51-
3. **Get your module connection string** -- now if you login to [Azure portal][lnk-portal]. Navigate to your IoT Hub and click IoT Devices. Find myFirstDevice, open it and you see myFirstModule was successfuly created. Copy the module connection string. It is needed in the next step.
52+
3. **Get your module connection string** -- now if you login to [Azure portal](https://portal.azure.com/). Navigate to your IoT Hub and click IoT Devices. Find myFirstDevice, open it and you see myFirstModule was successfuly created. Copy the module connection string. It is needed in the next step.
5253

53-
![Azure portal module detail][15]
54+
![Azure portal module detail](./media/iot-hub-csharp-csharp-module-twin-getstarted/module-detail.JPG)
5455

5556
4. **Create UpdateModuleTwinReportedProperties console app**
56-
Add the following `using` statements at the top of the **Program.cs** file:
57+
58+
Add the following `using` statements at the top of the **Program.cs** file:
5759

5860
```csharp
5961
using Microsoft.Azure.Devices.Client;
@@ -65,18 +67,22 @@ Add the following `using` statements at the top of the **Program.cs** file:
6567
Add the following fields to the **Program** class. Replace the placeholder value with the module connection string.
6668

6769
```csharp
68-
private const string ModuleConnectionString = "<Your module connection string>";
70+
private const string ModuleConnectionString =
71+
"<Your module connection string>";
6972
private static ModuleClient Client = null;
70-
static void ConnectionStatusChangeHandler(ConnectionStatus status, ConnectionStatusChangeReason reason)
73+
static void ConnectionStatusChangeHandler(ConnectionStatus status,
74+
ConnectionStatusChangeReason reason)
7175
{
72-
Console.WriteLine("Connection Status Changed to {0}; the reason is {1}", status, reason);
76+
Console.WriteLine("Connection Status Changed to {0}; the reason is {1}",
77+
status, reason);
7378
}
7479
```
7580

7681
Add the following method **OnDesiredPropertyChanged** to the **Program** class:
7782

7883
```csharp
79-
private static async Task OnDesiredPropertyChanged(TwinCollection desiredProperties, object userContext)
84+
private static async Task OnDesiredPropertyChanged(TwinCollection desiredProperties,
85+
object userContext)
8086
{
8187
Console.WriteLine("desired property change:");
8288
Console.WriteLine(JsonConvert.SerializeObject(desiredProperties));
@@ -95,11 +101,13 @@ Add the following `using` statements at the top of the **Program.cs** file:
95101
```csharp
96102
static void Main(string[] args)
97103
{
98-
Microsoft.Azure.Devices.Client.TransportType transport = Microsoft.Azure.Devices.Client.TransportType.Amqp;
104+
Microsoft.Azure.Devices.Client.TransportType transport =
105+
Microsoft.Azure.Devices.Client.TransportType.Amqp;
99106

100107
try
101108
{
102-
Client = ModuleClient.CreateFromConnectionString(ModuleConnectionString, transport);
109+
Client =
110+
ModuleClient.CreateFromConnectionString(ModuleConnectionString, transport);
103111
Client.SetConnectionStatusChangesHandler(ConnectionStatusChangeHandler);
104112
Client.SetDesiredPropertyUpdateCallbackAsync(OnDesiredPropertyChanged, null).Wait();
105113

@@ -129,6 +137,7 @@ Add the following `using` statements at the top of the **Program.cs** file:
129137
This code sample shows you how to retrieve the module twin and update reported properties with AMQP protocol. In public preview, we only support AMQP for module twin operations.
130138

131139
5. In addition to the above **Main** method, you can add below code block to send event to IoT Hub from your module:
140+
132141
```csharp
133142
Byte[] bytes = new Byte[2];
134143
bytes[0] = 0;
@@ -146,18 +155,5 @@ You are now ready to run the apps. In Visual Studio, in Solution Explorer, right
146155

147156
To continue getting started with IoT Hub and to explore other IoT scenarios, see:
148157

149-
* [Getting started with device management][lnk-device-management]
150-
* [Getting started with IoT Edge][lnk-iot-edge]
151-
152-
153-
<!-- Images. -->
154-
[13]: ./media\iot-hub-csharp-csharp-module-twin-getstarted/update-twins-csharp1.JPG
155-
[14]: ./media\iot-hub-csharp-csharp-module-twin-getstarted/install-sdk.png
156-
[15]: ./media\iot-hub-csharp-csharp-module-twin-getstarted/module-detail.JPG
157-
<!-- Links -->
158-
[lnk-hub-sdks]: iot-hub-devguide-sdks.md
159-
[lnk-free-trial]: http://azure.microsoft.com/pricing/free-trial/
160-
[lnk-portal]: https://portal.azure.com/
161-
162-
[lnk-device-management]: iot-hub-node-node-device-management-get-started.md
163-
[lnk-iot-edge]: ../iot-edge/tutorial-simulate-device-linux.md
158+
* [Getting started with device management](iot-hub-node-node-device-management-get-started.md)
159+
* [Getting started with IoT Edge](../iot-edge/tutorial-simulate-device-linux.md)

0 commit comments

Comments
 (0)