Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.IotHub.Models;
using Azure.ResourceManager.IotHub;

// Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/IoTHub/preview/2025-08-01-preview/examples/CreateOrReplace_Certificates_With_DeviceRegistryPolicy.json
// this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.

// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);

// this example assumes you already have this IotHubDescriptionResource created on azure
// for more information of creating IotHubDescriptionResource, please refer to the document of IotHubDescriptionResource
string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0";
string resourceGroupName = "myResourceGroup";
string resourceName = "testHub";
ResourceIdentifier iotHubDescriptionResourceId = IotHubDescriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName);
IotHubDescriptionResource iotHubDescription = client.GetIotHubDescriptionResource(iotHubDescriptionResourceId);

// get the collection of this IotHubCertificateDescriptionResource
IotHubCertificateDescriptionCollection collection = iotHubDescription.GetIotHubCertificateDescriptions();

// invoke the operation
string certificateName = "cert";
IotHubCertificateDescriptionData data = new IotHubCertificateDescriptionData
{
Properties = new IotHubCertificateProperties
{
Certificate = BinaryData.FromObjectAsJson("############################################"),
},
};
ArmOperation<IotHubCertificateDescriptionResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data);
IotHubCertificateDescriptionResource result = lro.Value;

// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
IotHubCertificateDescriptionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"sdkUrl": "https://github.com/Azure/azure-sdk-for-net/blob/Azure.ResourceManager.IotHub_1.2.0-beta.2/sdk/iothub/Azure.ResourceManager.IotHub/README.md"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.IotHub.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.IotHub;

// Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/IoTHub/preview/2025-08-01-preview/examples/CreateOrReplace_IoTHub_With_DeviceRegistry.json
// this example is just showing the usage of "IotHubResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.

// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);

// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);

// get the collection of this IotHubDescriptionResource
IotHubDescriptionCollection collection = resourceGroupResource.GetIotHubDescriptions();

// invoke the operation
string resourceName = "testHub";
IotHubDescriptionData data = new IotHubDescriptionData(new AzureLocation("centraluseuap"), new IotHubSkuInfo(IotHubSku.Gen2)
{
Capacity = 1L,
})
{
ETag = new ETag("AAAAAAFD6M4="),
Properties = new IotHubProperties
{
IPFilterRules = { },
NetworkRuleSets = new IotHubNetworkRuleSetProperties(true, new IotHubNetworkRuleSetIPRule[]
{
new IotHubNetworkRuleSetIPRule("rule1", "131.117.159.53")
{
Action = IotHubNetworkRuleIPAction.Allow,
},
new IotHubNetworkRuleSetIPRule("rule2", "157.55.59.128/25")
{
Action = IotHubNetworkRuleIPAction.Allow,
}
})
{
DefaultAction = IotHubNetworkRuleSetDefaultAction.Deny,
},
MinTlsVersion = "1.2",
EventHubEndpoints =
{
["events"] = new EventHubCompatibleEndpointProperties
{
RetentionTimeInDays = 1L,
PartitionCount = 2,
}
},
Routing = new IotHubRoutingProperties
{
Endpoints = new RoutingEndpoints
{
ServiceBusQueues = { },
ServiceBusTopics = { },
EventHubs = { },
StorageContainers = { },
},
Routes = { },
FallbackRoute = new IotHubFallbackRouteProperties(IotHubRoutingSource.DeviceMessages, new string[] { "events" }, true)
{
Name = "$fallback",
Condition = "true",
},
},
StorageEndpoints =
{
["$default"] = new IotHubStorageEndpointProperties("", "")
{
SasTtlAsIso8601 = XmlConvert.ToTimeSpan("PT1H"),
}
},
MessagingEndpoints =
{
["fileNotifications"] = new MessagingEndpointProperties
{
LockDurationAsIso8601 = XmlConvert.ToTimeSpan("PT1M"),
TtlAsIso8601 = XmlConvert.ToTimeSpan("PT1H"),
MaxDeliveryCount = 10,
}
},
EnableFileUploadNotifications = false,
CloudToDevice = new CloudToDeviceProperties
{
MaxDeliveryCount = 10,
DefaultTtlAsIso8601 = XmlConvert.ToTimeSpan("PT1H"),
Feedback = new CloudToDeviceFeedbackQueueProperties
{
LockDurationAsIso8601 = XmlConvert.ToTimeSpan("PT1M"),
TtlAsIso8601 = XmlConvert.ToTimeSpan("PT1H"),
MaxDeliveryCount = 10,
},
},
Features = IotHubCapability.None,
EnableDataResidency = true,
RootCertificate = new IotHubRootCertificateProperties
{
IsRootCertificateV2Enabled = true,
},
IPVersion = IotHubIPVersion.IPv4IPv6,
DeviceRegistry = new IotHubDeviceRegistry
{
NamespaceResourceId = new ResourceIdentifier("/subscriptions/ae24ff83-d2ca-4fc8-9717-05dae4bba489/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/namespaces/testNamespace"),
IdentityResourceId = new ResourceIdentifier("/subscriptions/ae24ff83-d2ca-4fc8-9717-05dae4bba489/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testIdentity"),
},
},
Tags = { },
};
ArmOperation<IotHubDescriptionResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data);
IotHubDescriptionResource result = lro.Value;

// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
IotHubDescriptionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"sdkUrl": "https://github.com/Azure/azure-sdk-for-net/blob/Azure.ResourceManager.IotHub_1.2.0-beta.2/sdk/iothub/Azure.ResourceManager.IotHub/README.md"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.IotHub.Models;
using Azure.ResourceManager.IotHub;

// Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/IoTHub/preview/2025-08-01-preview/examples/IotHub_ManualFailover.json
// this example is just showing the usage of "IotHub_ManualFailover" operation, for the dependent resources, they will have to be created separately.

// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);

// this example assumes you already have this IotHubDescriptionResource created on azure
// for more information of creating IotHubDescriptionResource, please refer to the document of IotHubDescriptionResource
string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0";
string resourceGroupName = "myResourceGroup";
string iotHubName = "testHub";
ResourceIdentifier iotHubDescriptionResourceId = IotHubDescriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, iotHubName);
IotHubDescriptionResource iotHubDescription = client.GetIotHubDescriptionResource(iotHubDescriptionResourceId);

// invoke the operation
IotHubFailoverContent content = new IotHubFailoverContent("testHub");
await iotHubDescription.ManualFailoverIotHubAsync(WaitUntil.Completed, content);

Console.WriteLine("Succeeded");
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"sdkUrl": "https://github.com/Azure/azure-sdk-for-net/blob/Azure.ResourceManager.IotHub_1.2.0-beta.2/sdk/iothub/Azure.ResourceManager.IotHub/README.md"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.IotHub.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.IotHub;

// Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/IoTHub/preview/2025-08-01-preview/examples/checkNameAvailability.json
// this example is just showing the usage of "IotHubResource_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately.

// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);

// this example assumes you already have this SubscriptionResource created on azure
// for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource
string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId);

// invoke the operation
IotHubNameAvailabilityContent content = new IotHubNameAvailabilityContent("test-request");
IotHubNameAvailabilityResponse result = await subscriptionResource.CheckIotHubNameAvailabilityAsync(content);

Console.WriteLine($"Succeeded: {result}");
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"sdkUrl": "https://github.com/Azure/azure-sdk-for-net/blob/Azure.ResourceManager.IotHub_1.2.0-beta.2/sdk/iothub/Azure.ResourceManager.IotHub/README.md"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.IotHub.Models;
using Azure.ResourceManager.IotHub;

// Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/IoTHub/preview/2025-08-01-preview/examples/iothub_certificatescreateorupdate.json
// this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.

// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);

// this example assumes you already have this IotHubDescriptionResource created on azure
// for more information of creating IotHubDescriptionResource, please refer to the document of IotHubDescriptionResource
string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0";
string resourceGroupName = "myResourceGroup";
string resourceName = "iothub";
ResourceIdentifier iotHubDescriptionResourceId = IotHubDescriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName);
IotHubDescriptionResource iotHubDescription = client.GetIotHubDescriptionResource(iotHubDescriptionResourceId);

// get the collection of this IotHubCertificateDescriptionResource
IotHubCertificateDescriptionCollection collection = iotHubDescription.GetIotHubCertificateDescriptions();

// invoke the operation
string certificateName = "cert";
IotHubCertificateDescriptionData data = new IotHubCertificateDescriptionData
{
Properties = new IotHubCertificateProperties
{
Certificate = BinaryData.FromObjectAsJson("############################################"),
},
};
ArmOperation<IotHubCertificateDescriptionResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data);
IotHubCertificateDescriptionResource result = lro.Value;

// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
IotHubCertificateDescriptionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"sdkUrl": "https://github.com/Azure/azure-sdk-for-net/blob/Azure.ResourceManager.IotHub_1.2.0-beta.2/sdk/iothub/Azure.ResourceManager.IotHub/README.md"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.IotHub.Models;
using Azure.ResourceManager.IotHub;

// Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/IoTHub/preview/2025-08-01-preview/examples/iothub_certificatesdelete.json
// this example is just showing the usage of "Certificates_Delete" operation, for the dependent resources, they will have to be created separately.

// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);

// this example assumes you already have this IotHubCertificateDescriptionResource created on azure
// for more information of creating IotHubCertificateDescriptionResource, please refer to the document of IotHubCertificateDescriptionResource
string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0";
string resourceGroupName = "myResourceGroup";
string resourceName = "myhub";
string certificateName = "cert";
ResourceIdentifier iotHubCertificateDescriptionResourceId = IotHubCertificateDescriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, certificateName);
IotHubCertificateDescriptionResource iotHubCertificateDescription = client.GetIotHubCertificateDescriptionResource(iotHubCertificateDescriptionResourceId);

// invoke the operation
string ifMatch = "AAAAAAAADGk=";
await iotHubCertificateDescription.DeleteAsync(WaitUntil.Completed, ifMatch);

Console.WriteLine("Succeeded");
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"sdkUrl": "https://github.com/Azure/azure-sdk-for-net/blob/Azure.ResourceManager.IotHub_1.2.0-beta.2/sdk/iothub/Azure.ResourceManager.IotHub/README.md"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.IotHub.Models;
using Azure.ResourceManager.IotHub;

// Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/IoTHub/preview/2025-08-01-preview/examples/iothub_certverify.json
// this example is just showing the usage of "Certificates_Verify" operation, for the dependent resources, they will have to be created separately.

// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);

// this example assumes you already have this IotHubCertificateDescriptionResource created on azure
// for more information of creating IotHubCertificateDescriptionResource, please refer to the document of IotHubCertificateDescriptionResource
string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0";
string resourceGroupName = "myResourceGroup";
string resourceName = "myFirstProvisioningService";
string certificateName = "cert";
ResourceIdentifier iotHubCertificateDescriptionResourceId = IotHubCertificateDescriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, certificateName);
IotHubCertificateDescriptionResource iotHubCertificateDescription = client.GetIotHubCertificateDescriptionResource(iotHubCertificateDescriptionResourceId);

// invoke the operation
string ifMatch = "AAAAAAAADGk=";
IotHubCertificateVerificationContent content = new IotHubCertificateVerificationContent
{
Certificate = BinaryData.FromObjectAsJson("#####################################"),
};
IotHubCertificateDescriptionResource result = await iotHubCertificateDescription.VerifyAsync(ifMatch, content);

// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
IotHubCertificateDescriptionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"sdkUrl": "https://github.com/Azure/azure-sdk-for-net/blob/Azure.ResourceManager.IotHub_1.2.0-beta.2/sdk/iothub/Azure.ResourceManager.IotHub/README.md"}
Loading