You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: includes/iot-hub-howto-auth-device-cert-dotnet.md
+16-2Lines changed: 16 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,12 +16,26 @@ To connect a device to IoT Hub using an X.509 certificate:
16
16
17
17
1. Use [DeviceAuthenticationWithX509Certificate](/dotnet/api/microsoft.azure.devices.client.deviceauthenticationwithx509certificate) to create an object that contains device and certificate information. `DeviceAuthenticationWithX509Certificate` is passed as the second parameter to `DeviceClient.Create` (step 2).
18
18
19
-
1. Use [DeviceClient.Create](/dotnet/api/microsoft.azure.devices.client.deviceclient.create?view=azure-dotnet&branch=main#microsoft-azure-devices-client-deviceclient-create(system-string-microsoft-azure-devices-client-iauthenticationmethod-microsoft-azure-devices-client-transporttype)) to connect the device to IoT Hub using an X.509 certificate.
19
+
1. Use [DeviceClient.Create](/dotnet/api/microsoft.azure.devices.client.deviceclient.create?view=azure-dotnet&#microsoft-azure-devices-client-deviceclient-create(system-string-microsoft-azure-devices-client-iauthenticationmethod-microsoft-azure-devices-client-transporttype)) to connect the device to IoT Hub using an X.509 certificate.
20
20
21
-
In this example, the device and certificate information has been populated in the `auth``DeviceAuthenticationWithX509Certificate` object that is passed to `DeviceClient.Create`. An example of `DeviceAuthenticationWithX509Certificate` information population is omitted because of the flexible nature of how the certificate information can be added.
21
+
In this example, the device and certificate information are populated in the `auth``DeviceAuthenticationWithX509Certificate` object that is passed to `DeviceClient.Create`.
Copy file name to clipboardExpand all lines: includes/iot-hub-howto-file-upload-dotnet.md
+32-6Lines changed: 32 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -120,21 +120,47 @@ You can create a backend service to receive file upload notification messages fr
120
120
121
121
The [ServiceClient](/dotnet/api/microsoft.azure.devices.serviceclient) class contains methods that services can use to receive file upload notifications.
122
122
123
-
To receive file upload notification:
123
+
### Add service NuGet Package
124
124
125
-
1. Call [CreateFromConnectionString](/dotnet/api/microsoft.azure.devices.serviceclient.createfromconnectionstring) to connect to IoT hub. Pass the IoT hub primary connection string.
126
-
1. Create a [CancellationToken](/dotnet/api/azure.core.httpmessage.cancellationtoken?#azure-core-httpmessage-cancellationtoken).
127
-
1. Call [GetFileNotificationReceiver](/dotnet/api/microsoft.azure.devices.serviceclient.getfilenotificationreceiver?#microsoft-azure-devices-serviceclient-getfilenotificationreceiver) to create a notification receiver.
128
-
1. Use a loop with [ReceiveAsync](/dotnet/api/microsoft.azure.devices.receiver-1.receiveasync?#microsoft-azure-devices-receiver-1-receiveasync(system-threading-cancellationtoken)) to wait for the file upload notification.
125
+
Backend service applications require the **Microsoft.Azure.Devices** NuGet package.
126
+
127
+
### Connect to IoT hub
128
+
129
+
You can connect a backend service to IoT Hub using the following methods:
Connect a backend application to a device using [CreateFromConnectionString](/dotnet/api/microsoft.azure.devices.registrymanager.createfromconnectionstring). Your application needs **service connect** permission. Supply this shared access policy connection string as a parameter to `fromConnectionString`. For more information about shared access policies, see [Control access to IoT Hub with shared access signatures](/azure/iot-hub/authenticate-authorize-sas).
1. Create a [CancellationToken](/dotnet/api/azure.core.httpmessage.cancellationtoken?#azure-core-httpmessage-cancellationtoken).
158
+
1. Call [GetFileNotificationReceiver](/dotnet/api/microsoft.azure.devices.serviceclient.getfilenotificationreceiver?#microsoft-azure-devices-serviceclient-getfilenotificationreceiver) to create a notification receiver.
159
+
1. Use a loop with [ReceiveAsync](/dotnet/api/microsoft.azure.devices.receiver-1.receiveasync?#microsoft-azure-devices-receiver-1-receiveasync(system-threading-cancellationtoken)) to wait for the file upload notification.
Copy file name to clipboardExpand all lines: includes/iot-hub-howto-file-upload-java.md
+3-8Lines changed: 3 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -123,18 +123,13 @@ Free the `client` resources.
123
123
client.closeNow();
124
124
```
125
125
126
-
## Receive a file upload notification in a backend application
126
+
## Create a backend application
127
127
128
-
You can create a backend application to receive file upload notifications.
129
-
130
-
To create a file upload notification application:
131
-
132
-
1. Connect to the IoT hub service client
133
-
1. Check for a file upload notification
128
+
This section describes how to receive a file upload notification in a backend application.
134
129
135
130
The [ServiceClient](/java/api/com.azure.core.annotation.serviceclient) class contains methods that services can use to receive file upload notifications.
136
131
137
-
### Connect to the IoT hub service client
132
+
### Connect to the IoT Hub
138
133
139
134
Create a `IotHubServiceClientProtocol` object. The connection uses the `AMQPS` protocol.
This article describes howto use the [Azure IoT SDK for Node.js](https://github.com/Azure/azure-iot-sdk-node) to create a device app to upload a file and backend service application receive file upload notification.
17
17
18
-
* Upload a file from a device application
19
-
* Receive file upload notification in a backend application
20
-
21
-
## Upload a file from a device application
18
+
## Create a device application
22
19
23
20
This section describes how to upload a file from a device to an IoT hub using the [azure-iot-device](/javascript/api/azure-iot-device) package in the Azure IoT SDK for Node.js.
*`Http` - When using `Http`, the `Client` instance checks for messages from IoT Hub infrequently (a minimum of every 25 minutes).
67
+
*`Mqtt`
68
+
*`MqttWs`
69
+
*`AmqpWs`
70
+
71
+
Install needed transport protocols on your development machine.
72
+
73
+
For example, this command installs the `Amqp` protocol:
74
+
75
+
```cmd/sh
76
+
npm install azure-iot-device-amqp --save
77
+
```
78
+
79
+
For more information about the differences between MQTT, AMQP, and HTTPS support, see [Cloud-to-device communications guidance](../articles/iot-hub/iot-hub-devguide-c2d-guidance.md) and [Choose a communication protocol](../articles/iot-hub/iot-hub-devguide-protocols.md).
80
+
81
+
##### Create a client object
82
+
83
+
Create a `Client` object using the installed package.
84
+
85
+
For example:
86
+
87
+
```javascript
88
+
constClient=require('azure-iot-device').Client;
89
+
```
90
+
91
+
##### Create a protocol object
92
+
93
+
Create a `Protocol` object using an installed transport package.
let client =Client.fromConnectionString(deviceConnectionString, Protocol);
114
+
```
115
+
116
+
##### Open the connection to IoT Hub
53
117
54
-
Use [getBlobSharedAccessSignature](/javascript/api/azure-iot-device/client?#azure-iot-device-client-getblobsharedaccesssignature) to get the linked storage account SAS token from IoT hub. As described in prerequisites, the IoT hub is linked to the Blob Storage.
118
+
Use the [open](/javascript/api/azure-iot-device/client?#azure-iot-device-client-open) method to open connection between an IoT device and IoT Hub.
119
+
120
+
For example:
121
+
122
+
```javascript
123
+
client.open(function(err) {
124
+
if (err) {
125
+
console.error('error connecting to hub: '+ err);
126
+
process.exit(1);
127
+
}
128
+
})
129
+
```
130
+
131
+
#### Get a SAS URI from IoT hub
132
+
133
+
Use [getBlobSharedAccessSignature](/javascript/api/azure-iot-device/client?#azure-iot-device-client-getblobsharedaccesssignature) to get the linked storage account SAS token from IoT hub.
55
134
56
135
For example:
57
136
@@ -65,7 +144,7 @@ throw new errors.ArgumentError('Invalid upload parameters');
The SDK includes an [upload to blob advanced](https://github.com/Azure/azure-iot-sdk-node/blob/main/device/samples/javascript/upload_to_blob_advanced.js) sample.
226
+
227
+
## Create a backend application
228
+
229
+
This section describes how to receive file upload notification in a backend application.
230
+
231
+
### Install service SDK package
232
+
233
+
Run this command to install **azure-iothub** on your development machine:
234
+
235
+
```cmd/sh
236
+
npm install azure-iothub --save
237
+
```
238
+
128
239
## Receive file upload notification in a backend application
129
240
130
241
You can create a backend application to check the IoT hub service client for device file upload notifications.
@@ -185,7 +296,3 @@ if (err) {
185
296
});
186
297
}
187
298
```
188
-
189
-
### SDK file upload sample
190
-
191
-
The SDK includes an [upload to blob advanced](https://github.com/Azure/azure-iot-sdk-node/blob/main/device/samples/javascript/upload_to_blob_advanced.js) sample.
0 commit comments