Skip to content

Commit

Permalink
Update and publish samples for 1.3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Schulte committed Oct 5, 2017
1 parent 0d3f41b commit 7f03523
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Asset/create_resources_with_msi.sh
Expand Up @@ -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
az login --msi
az storage account create -n $1 -g $2 -l $3 --sku Premium_LRS
126 changes: 125 additions & 1 deletion Common/Utilities.cs
Expand Up @@ -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
{
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand All @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions DeployUsingARMTemplateWithProgress.csproj
Expand Up @@ -18,8 +18,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.8" />
<PackageReference Include="Microsoft.Azure.Management.Fluent" Version="1.2.0" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.10" />
<PackageReference Include="Microsoft.Azure.Management.Fluent" Version="1.3.0" />
<PackageReference Include="CoreFTP" Version="1.2.0" />
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="0.0.2-preview" />
<PackageReference Include="SSH.NET" Version="2016.0.0" />
Expand Down
34 changes: 17 additions & 17 deletions 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.
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

0 comments on commit 7f03523

Please sign in to comment.