From 0dc757e1b52a2986dfcf67aee44e37c10f45df50 Mon Sep 17 00:00:00 2001 From: Dan Schulte Date: Thu, 5 Oct 2017 11:32:33 -0700 Subject: [PATCH] Update and publish samples for 1.3 release --- Asset/create_resources_with_msi.sh | 4 +- Common/Utilities.cs | 126 +++++++++++++++++++++++++++- LICENSE | 34 ++++---- ManageVirtualMachineScaleSet.csproj | 4 +- 4 files changed, 146 insertions(+), 22 deletions(-) diff --git a/Asset/create_resources_with_msi.sh b/Asset/create_resources_with_msi.sh index b3100e2..1013ab6 100644 --- a/Asset/create_resources_with_msi.sh +++ b/Asset/create_resources_with_msi.sh @@ -4,5 +4,5 @@ /usr/bin/yes | sudo apt install python-pip /usr/bin/yes | sudo pip install --upgrade pip sudo pip install azure-cli -az login -u $1@$2 -az storage account create -n $3 -g $4 -l $5 --sku Premium_LRS \ No newline at end of file +az login --msi +az storage account create -n $1 -g $2 -l $3 --sku Premium_LRS \ No newline at end of file diff --git a/Common/Utilities.cs b/Common/Utilities.cs index 22226c5..c207d91 100644 --- a/Common/Utilities.cs +++ b/Common/Utilities.cs @@ -40,6 +40,7 @@ using Microsoft.Azure.Management.Graph.RBAC.Fluent; using Microsoft.Azure.Management.Graph.RBAC.Fluent.Models; using Microsoft.Azure.Management.Network.Fluent.Models; +using Microsoft.Azure.Management.ContainerInstance.Fluent; namespace Microsoft.Azure.Management.Samples.Common { @@ -783,11 +784,30 @@ public static void PrintVirtualNetwork(INetwork network) { info.Append("\n\tSubnet: ").Append(subnet.Name) .Append("\n\t\tAddress prefix: ").Append(subnet.AddressPrefix); + + // Output associated NSG var subnetNsg = subnet.GetNetworkSecurityGroup(); if (subnetNsg != null) { info.Append("\n\t\tNetwork security group: ").Append(subnetNsg.Id); } + + // Output associated route table + var routeTable = subnet.GetRouteTable(); + if (routeTable != null) + { + info.Append("\n\tRoute table ID: ").Append(routeTable.Id); + } + } + + // Output peerings + foreach (var peering in network.Peerings.List()) + { + info.Append("\n\tPeering: ").Append(peering.Name) + .Append("\n\t\tRemote network ID: ").Append(peering.RemoteNetworkId) + .Append("\n\t\tPeering state: ").Append(peering.State) + .Append("\n\t\tIs traffic forwarded from remote network allowed? ").Append(peering.IsTrafficForwardingFromRemoteNetworkAllowed) + .Append("\n\t\tGateway use: ").Append(peering.GatewayUse); } Utilities.Log(info.ToString()); @@ -1573,6 +1593,92 @@ public static void Print(IRegistry azureRegistry) Log(info.ToString()); } + public static void Print(IContainerGroup containerGroup) + { + StringBuilder info = new StringBuilder(); + + info = new StringBuilder().Append("Container Group: ").Append(containerGroup.Id) + .Append("Name: ").Append(containerGroup.Name) + .Append("\n\tResource group: ").Append(containerGroup.ResourceGroupName) + .Append("\n\tRegion: ").Append(containerGroup.RegionName) + .Append("\n\tTags: ").Append(containerGroup.Tags) + .Append("\n\tOS type: ").Append(containerGroup.OSType.Value); + + if (containerGroup.IPAddress != null) + { + info.Append("\n\tPublic IP address: ").Append(containerGroup.IPAddress); + info.Append("\n\tExternal TCP ports:"); + foreach (int port in containerGroup.ExternalTcpPorts) + { + info.Append(" ").Append(port); + } + info.Append("\n\tExternal UDP ports:"); + foreach (int port in containerGroup.ExternalUdpPorts) + { + info.Append(" ").Append(port); + } + } + if (containerGroup.ImageRegistryServers.Count > 0) + { + info.Append("\n\tPrivate Docker image registries:"); + foreach (string server in containerGroup.ImageRegistryServers) + { + info.Append(" ").Append(server); + } + } + if (containerGroup.Volumes.Count > 0) + { + info.Append("\n\tVolume mapping: "); + foreach (var entry in containerGroup.Volumes) + { + info.Append("\n\t\tName: ").Append(entry.Key).Append(" -> ").Append(entry.Value.AzureFile.ShareName); + } + } + if (containerGroup.Containers.Count > 0) + { + info.Append("\n\tContainer instances: "); + foreach (var entry in containerGroup.Containers) + { + var container = entry.Value; + info.Append("\n\t\tName: ").Append(entry.Key).Append(" -> ").Append(container.Image); + info.Append("\n\t\t\tResources: "); + info.Append(container.Resources.Requests.Cpu).Append(" CPUs "); + info.Append(container.Resources.Requests.MemoryInGB).Append(" GB"); + info.Append("\n\t\t\tPorts:"); + foreach (var port in container.Ports) + { + info.Append(" ").Append(port.Port); + } + if (container.VolumeMounts != null) + { + info.Append("\n\t\t\tVolume mounts:"); + foreach (var volumeMount in container.VolumeMounts) + { + info.Append(" ").Append(volumeMount.Name).Append("->").Append(volumeMount.MountPath); + } + } + if (container.Command != null) + { + info.Append("\n\t\t\tStart commands:"); + foreach (var command in container.Command) + { + info.Append("\n\t\t\t\t").Append(command); + } + } + if (container.EnvironmentVariables != null) + { + info.Append("\n\t\t\tENV vars:"); + foreach (var envVar in container.EnvironmentVariables) + { + info.Append("\n\t\t\t\t").Append(envVar.Name).Append("=").Append(envVar.Value); + } + } + } + } + + Log(info.ToString()); + } + /** * Print an Azure Container Service. * @param containerService an Azure Container Service @@ -1594,7 +1700,7 @@ public static void Print(IContainerService containerService) .Append("\n\t\tAgent pool leaf domain label: ").Append(containerService.AgentPoolLeafDomainLabel) .Append("\n\tLinux user name: ").Append(containerService.LinuxRootUsername) .Append("\n\tSSH key: ").Append(containerService.SshKey); - if (containerService.OrchestratorType == ContainerServiceOchestratorTypes.Kubernetes) + if (containerService.OrchestratorType == ContainerServiceOrchestratorTypes.Kubernetes) { info.Append("\n\tName: ").Append(containerService.ServicePrincipalClientId); } @@ -1912,6 +2018,24 @@ public static void Print(INextHop resource) Utilities.Log(sb.ToString()); } + public static void Print(IVirtualNetworkGatewayConnection resource) + { + StringBuilder sb = new StringBuilder("Virtual network gateway connection: ") + .Append("\n\tId: ").Append(resource.Id) + .Append("\n\tName: ").Append(resource.Name) + .Append("\n\tResource group: ").Append(resource.ResourceGroupName) + .Append("\n\tRegion: ").Append(resource.RegionName) + .Append("\n\tConnection type: ").Append(resource.ConnectionType) + .Append("\n\tConnection status: ").Append(resource.ConnectionStatus.Value) + .Append("\n\tFirst virtual network gateway id: ").Append(resource.VirtualNetworkGateway1Id) + .Append("\n\tSecond virtual network gateway id: ").Append(resource.VirtualNetworkGateway2Id) + .Append("\n\tLocal network gateway id: ").Append(resource.LocalNetworkGateway2Id) + .Append("\n\tBgp enabled: ").Append(resource.IsBgpEnabled) + .Append("\n\tEgressBytesTransferred: ").Append(resource.EgressBytesTransferred) + .Append("\n\tIngressBytesTransferred: ").Append(resource.IngressBytesTransferred); + Utilities.Log(sb.ToString()); + } + public static void CreateCertificate(string domainName, string pfxPath, string password) { if (!IsRunningMocked) diff --git a/LICENSE b/LICENSE index d8d98a8..d1ca00f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -The MIT License (MIT) + MIT License -Copyright (c) 2015 Microsoft Corporation + Copyright (c) Microsoft Corporation. All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE \ No newline at end of file diff --git a/ManageVirtualMachineScaleSet.csproj b/ManageVirtualMachineScaleSet.csproj index b6ea06e..05336c8 100644 --- a/ManageVirtualMachineScaleSet.csproj +++ b/ManageVirtualMachineScaleSet.csproj @@ -18,8 +18,8 @@ - - + +