Exemplo n.º 1
0
        public async Task CreateNamespaceAndGetEventhubCollection()
        {
            _resourceGroup = await CreateResourceGroupAsync();

            string namespaceName = await CreateValidNamespaceName("testnamespacemgmt");

            EventHubNamespaceCollection namespaceCollection = _resourceGroup.GetEventHubNamespaces();
            EventHubNamespace           eventHubNamespace   = (await namespaceCollection.CreateOrUpdateAsync(true, namespaceName, new EventHubNamespaceData(DefaultLocation))).Value;

            _eventHubCollection = eventHubNamespace.GetEventHubs();
        }
Exemplo n.º 2
0
        public async Task CreateNamespaceAndGetEventhubCollection()
        {
            _resourceGroup = await CreateResourceGroupAsync();

            string namespaceName = await CreateValidNamespaceName("testnamespacemgmt");

            EventHubNamespaceCollection namespaceCollection = _resourceGroup.GetEventHubNamespaces();
            EventHubNamespace           eHNamespace         = (await namespaceCollection.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName, new EventHubNamespaceData(DefaultLocation))).Value;
            EventHubCollection          eventhubCollection  = eHNamespace.GetEventHubs();
            string eventhubName = Recording.GenerateAssetName("eventhub");

            _eventHub = (await eventhubCollection.CreateOrUpdateAsync(WaitUntil.Completed, eventhubName, new EventHubData())).Value;
            _consumerGroupCollection = _eventHub.GetConsumerGroups();
        }
Exemplo n.º 3
0
        public async Task ChangelogSample()
        {
#endif
string namespaceName = "myNamespace";
string eventhubName = "myEventhub";
string resourceGroupName = "myResourceGroup";
ArmClient client = new ArmClient(new DefaultAzureCredential());
Subscription subscription = await client.GetDefaultSubscriptionAsync();
ResourceGroup resourceGroup = subscription.GetResourceGroups().Get(resourceGroupName);
//create namespace
EventHubNamespaceData parameters = new EventHubNamespaceData(AzureLocation.WestUS)
{
    Sku = new Models.Sku(SkuName.Standard)
    {
        Tier = SkuTier.Standard,
    }
};
parameters.Tags.Add("tag1", "value1");
parameters.Tags.Add("tag2", "value2");
EventHubNamespaceCollection eHNamespaceCollection = resourceGroup.GetEventHubNamespaces();
EventHubNamespace eventHubNamespace = eHNamespaceCollection.CreateOrUpdate(true, namespaceName, parameters).Value;

//create eventhub
EventHubCollection eventHubCollection = eventHubNamespace.GetEventHubs();
EventHubData eventHubData = new EventHubData()
{
    MessageRetentionInDays = 4,
    PartitionCount = 4,
    Status = EntityStatus.Active,
    CaptureDescription = new CaptureDescription()
    {
        Enabled = true,
        Encoding = EncodingCaptureDescription.Avro,
        IntervalInSeconds = 120,
        SizeLimitInBytes = 10485763,
        Destination = new EventHubDestination()
        {
            Name = "EventHubArchive.AzureBlockBlob",
            BlobContainer = "Container",
            ArchiveNameFormat = "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}",
            StorageAccountResourceId = subscription.Id.ToString() + "/resourcegroups/v-ajnavtest/providers/Microsoft.Storage/storageAccounts/testingsdkeventhubnew"
        },
        SkipEmptyArchives = true
    }
};
EventHub eventHub = eventHubCollection.CreateOrUpdate(true, eventhubName, eventHubData).Value;
            #endregion
        }
Exemplo n.º 4
0
        public async Task CreateNamespace()
        {
            #region Snippet:Managing_EventHubs_DefaultSubscription
            ArmClient    armClient    = new ArmClient(new DefaultAzureCredential());
            Subscription subscription = await armClient.GetDefaultSubscriptionAsync();

            #endregion
            #region Snippet:Managing_EventHubs_CreateResourceGroup
            string        rgName   = "myRgName";
            AzureLocation location = AzureLocation.WestUS2;
            ArmOperation <ResourceGroup> operation = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, new ResourceGroupData(location));

            ResourceGroup resourceGroup = operation.Value;
            #endregion
            #region Snippet:Managing_EventHubs_CreateNamespace
            string namespaceName = "myNamespace";
            EventHubNamespaceCollection namespaceCollection = resourceGroup.GetEventHubNamespaces();
            EventHubNamespace           eHNamespace         = (await namespaceCollection.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName, new EventHubNamespaceData(location))).Value;
            EventHubCollection          eventHubCollection  = eHNamespace.GetEventHubs();
            #endregion
            this.eventHubCollection = eventHubCollection;
        }