From cfa9a4b47a401a0cb32637a478985c98750d0cc8 Mon Sep 17 00:00:00 2001 From: Azure-Fluent Date: Tue, 14 Jan 2020 13:01:26 +0800 Subject: [PATCH] Release 1.30.0 --- Asset/NetworkTestCertificate1.cer | 17 --- Asset/install_apache.sh | 2 + Common/Utilities.cs | 236 +++++++++++++++++++++++------- ManageContainerRegistry.csproj | 6 +- README.md | 46 +++--- 5 files changed, 209 insertions(+), 98 deletions(-) delete mode 100644 Asset/NetworkTestCertificate1.cer diff --git a/Asset/NetworkTestCertificate1.cer b/Asset/NetworkTestCertificate1.cer deleted file mode 100644 index 8ab238a..0000000 --- a/Asset/NetworkTestCertificate1.cer +++ /dev/null @@ -1,17 +0,0 @@ ------BEGIN CERTIFICATE----- -MIICwTCCAamgAwIBAgIEJk52uDANBgkqhkiG9w0BAQsFADARMQ8wDQYDVQQDEwZt -eVRlc3QwHhcNMTYxMTEyMDExMzI2WhcNMjYxMTEwMDExMzI2WjARMQ8wDQYDVQQD -EwZteVRlc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCbnzJF3c+/ -scbgRynsixxmWl3GdZiQHvoAcUbWeGdl1uo0RT6Xy8BCKdXCBQoYmxng3XbvSKdb -vPe2bkGT9A08qU8yUqT0bEIqW5FBgx5dEsw4Tx+n9p7QhJMaw6X54VuJUbyUp4DZ -vTle99n00jGHpt6TBwjoEI6sDOS7XnenY9YR1GXDcM3qWbvIWTrzJaqys1RgSbxg -cRILn885VZZLuuyjU6WhJQFfx/i3GXKT3ZP8rU3e6d7q0PjVAKyFwaMNVeU4VmDi -7knGhyC84IYo1OFKsAcSVCaxdSQbOGaexvFaj2jjoKfvY3dn4ioo3yIzSMJglfMA -HHX/xzTkx27lAgMBAAGjITAfMB0GA1UdDgQWBBSCQubqxdIPUu/PEWqRlSXpKLFu -qTANBgkqhkiG9w0BAQsFAAOCAQEACp6YCKt8FjkPunlCIJPVYxRYQ3st7G/JF2y9 -0EiPZW8LsB8QS/GPrchBaZdOi1SMLkDvS2Bz37unJK7YF6X/IXmgacCJJcNyWr/0 -IuDT4f0hu3T+Xyfe0TUxVIC4Cb8icw5IpF2EagVacERTZGB/u38Y77Fa3JRSx4wZ -nsHTmP4JSKuOxRZknDw5/gHGHfHr+9nycNJ7IHrYKKCEEgkhDUvUax3fN3TWyZap -R98S+RQaJ3rLaNiNqVjuGrbHjReQikTtZwCtlpM8VHoviyyTUE7xkekM2p4YhDpD -ZDN+i2OgUKsSKmDwrZTC732D0G7r80fl96ezNM9O7qh457ihVA== ------END CERTIFICATE----- diff --git a/Asset/install_apache.sh b/Asset/install_apache.sh index 1789520..2e2603d 100644 --- a/Asset/install_apache.sh +++ b/Asset/install_apache.sh @@ -1,5 +1,7 @@ #!/bin/bash +sudo apt-get install -f + sudo apt-get update # install apache diff --git a/Common/Utilities.cs b/Common/Utilities.cs index d7449ec..28927cd 100644 --- a/Common/Utilities.cs +++ b/Common/Utilities.cs @@ -3,7 +3,6 @@ using Microsoft.Azure.Management.AppService.Fluent; using Microsoft.Azure.Management.AppService.Fluent.Models; -using Microsoft.Azure.Management.Batch.Fluent; using Microsoft.Azure.Management.Compute.Fluent; using Microsoft.Azure.Management.ContainerRegistry.Fluent; using Microsoft.Azure.Management.ContainerRegistry.Fluent.Models; @@ -48,6 +47,7 @@ using Microsoft.Azure.Management.Msi.Fluent; using Microsoft.Azure.Management.Eventhub.Fluent; using Microsoft.Azure.Management.Monitor.Fluent; +using Microsoft.Azure.Management.PrivateDns.Fluent; namespace Microsoft.Azure.Management.Samples.Common { @@ -773,55 +773,6 @@ public static void PrintAvailabilitySet(IAvailabilitySet resource) .ToString()); } - public static void PrintBatchAccount(IBatchAccount batchAccount) - { - var applicationsOutput = new StringBuilder().Append("\n\tapplications: "); - - if (batchAccount.Applications.Count > 0) - { - foreach (var applicationEntry in batchAccount.Applications) - { - var application = applicationEntry.Value; - var applicationPackages = new StringBuilder().Append("\n\t\t\tapplicationPackages : "); - - foreach (var applicationPackageEntry in application.ApplicationPackages) - { - var applicationPackage = applicationPackageEntry.Value; - var singleApplicationPackage = new StringBuilder().Append("\n\t\t\t\tapplicationPackage : " + applicationPackage.Name); - singleApplicationPackage.Append("\n\t\t\t\tapplicationPackageState : " + applicationPackage.State); - - applicationPackages.Append(singleApplicationPackage); - singleApplicationPackage.Append("\n"); - } - - var singleApplication = new StringBuilder().Append("\n\t\tapplication: " + application.Name); - singleApplication.Append("\n\t\tdisplayName: " + application.DisplayName); - singleApplication.Append("\n\t\tdefaultVersion: " + application.DefaultVersion); - singleApplication.Append(applicationPackages); - applicationsOutput.Append(singleApplication); - applicationsOutput.Append("\n"); - } - } - - Utilities.Log(new StringBuilder().Append("BatchAccount: ").Append(batchAccount.Id) - .Append("Name: ").Append(batchAccount.Name) - .Append("\n\tResource group: ").Append(batchAccount.ResourceGroupName) - .Append("\n\tRegion: ").Append(batchAccount.Region) - .Append("\n\tTags: ").Append(FormatDictionary(batchAccount.Tags)) - .Append("\n\tAccountEndpoint: ").Append(batchAccount.AccountEndpoint) - .Append("\n\tPoolQuota: ").Append(batchAccount.PoolQuota) - .Append("\n\tActiveJobAndJobScheduleQuota: ").Append(batchAccount.ActiveJobAndJobScheduleQuota) - .Append("\n\tStorageAccount: ").Append(batchAccount.AutoStorage == null ? "No storage account attached" : batchAccount.AutoStorage.StorageAccountId) - .Append(applicationsOutput) - .ToString()); - } - - public static void PrintBatchAccountKey(BatchAccountKeys batchAccountKeys) - { - Utilities.Log("Primary Key (" + batchAccountKeys.Primary + ") Secondary key = (" - + batchAccountKeys.Secondary + ")"); - } - public static void PrintNetworkSecurityGroup(INetworkSecurityGroup resource) { var nsgOutput = new StringBuilder(); @@ -997,6 +948,26 @@ public static void PrintLoadBalancer(ILoadBalancer loadBalancer) } } + // Show HTTPS probes + info.Append("\n\tHTTPS probes: ") + .Append(loadBalancer.HttpsProbes.Count); + foreach (var probe in loadBalancer.HttpsProbes.Values) + { + info.Append("\n\t\tProbe name: ").Append(probe.Name) + .Append("\n\t\t\tPort: ").Append(probe.Port) + .Append("\n\t\t\tInterval in seconds: ").Append(probe.IntervalInSeconds) + .Append("\n\t\t\tRetries before unhealthy: ").Append(probe.NumberOfProbes) + .Append("\n\t\t\tHTTPS request path: ").Append(probe.RequestPath); + + // Show associated load balancing rules + info.Append("\n\t\t\tReferenced from load balancing rules: ") + .Append(probe.LoadBalancingRules.Count); + foreach (var rule in probe.LoadBalancingRules.Values) + { + info.Append("\n\t\t\t\tName: ").Append(rule.Name); + } + } + // Show load balancing rules info.Append("\n\tLoad balancing rules: ") .Append(loadBalancer.LoadBalancingRules.Count); @@ -1166,8 +1137,8 @@ public static void PrintVault(IVault vault) foreach (var accessPolicy in vault.AccessPolicies) { info.Append("\n\t\tIdentity:").Append(accessPolicy.ObjectId) - .Append("\n\t\tKey permissions: ").Append(FormatCollection(accessPolicy.Permissions.Keys)) - .Append("\n\t\tSecret permissions: ").Append(FormatCollection(accessPolicy.Permissions.Secrets)); + .Append("\n\t\tKey permissions: ").Append(FormatCollection(accessPolicy.Permissions.Keys.Select(key => key.ToString()))) + .Append("\n\t\tSecret permissions: ").Append(FormatCollection(accessPolicy.Permissions.Secrets.Select(secret => secret.ToString()))); } Utilities.Log(info.ToString()); @@ -1343,7 +1314,7 @@ public static void PrintSqlServer(ISqlServer sqlServer) Utilities.Log(builder.ToString()); } - public static void PrintDatabase(ISqlDatabase database) + public static void PrintDatabase(Microsoft.Azure.Management.Sql.Fluent.ISqlDatabase database) { var builder = new StringBuilder().Append("Sql Database: ").Append(database.Id) .Append("Name: ").Append(database.Name) @@ -1763,6 +1734,155 @@ public static void Print(IDnsZone dnsZone) Utilities.Log(builder.ToString()); } + public static void Print(IPrivateDnsZone privateDnsZone) + { + var builder = new StringBuilder(); + builder.Append("Private Dns Zone: ").Append(privateDnsZone.Id) + .Append("\n\tName (Top level domain): ").Append(privateDnsZone.Name) + .Append("\n\tResource group: ").Append(privateDnsZone.ResourceGroupName) + .Append("\n\tRegion: ").Append(privateDnsZone.RegionName) + .Append("\n\tTags: ").Append(privateDnsZone.Tags) + .Append("\n\tNumber of record sets: ").Append(privateDnsZone.NumberOfRecordSets) + .Append("\n\tMax number of record sets: ").Append(privateDnsZone.MaxNumberOfRecordSets) + .Append("\n\tNumber of virtual network links: ").Append(privateDnsZone.NumberOfVirtualNetworkLinks) + .Append("\n\tMax number of virtual network links: ").Append(privateDnsZone.NumberOfVirtualNetworkLinks) + .Append("\n\tNumber of virtual network links with registration: ").Append(privateDnsZone.NumberOfVirtualNetworkLinksWithRegistration) + .Append("\n\tMax number of virtual network links with registration: ").Append(privateDnsZone.MaxNumberOfVirtualNetworkLinksWithRegistration); + + var aRecordSets = privateDnsZone.ARecordSets.List(); + builder.Append("\n\tA Record sets:"); + foreach (var aRecordSet in aRecordSets) + { + builder.Append("\n\t\tId: ").Append(aRecordSet.Id) + .Append("\n\t\tName: ").Append(aRecordSet.Name) + .Append("\n\t\tTtl (seconds): ").Append(aRecordSet.TimeToLive) + .Append("\n\t\tIp v4 addresses: "); + foreach (var ipAddress in aRecordSet.IPv4Addresses) + { + builder.Append("\n\t\t\t").Append(ipAddress); + } + } + + var aaaaRecordSets = privateDnsZone.AaaaRecordSets.List(); + builder.Append("\n\tAAAA Record sets:"); + foreach (var aaaaRecordSet in aaaaRecordSets) + { + builder.Append("\n\t\tId: ").Append(aaaaRecordSet.Id) + .Append("\n\t\tName: ").Append(aaaaRecordSet.Name) + .Append("\n\t\tTtl (seconds): ").Append(aaaaRecordSet.TimeToLive) + .Append("\n\t\tIp v6 addresses: "); + foreach (var ipAddress in aaaaRecordSet.IPv6Addresses) + { + builder.Append("\n\t\t\t").Append(ipAddress); + } + } + + var cnameRecordSets = privateDnsZone.CnameRecordSets.List(); + builder.Append("\n\tCNAME Record sets:"); + foreach (var cnameRecordSet in cnameRecordSets) + { + builder.Append("\n\t\tId: ").Append(cnameRecordSet.Id) + .Append("\n\t\tName: ").Append(cnameRecordSet.Name) + .Append("\n\t\tTtl (seconds): ").Append(cnameRecordSet.TimeToLive) + .Append("\n\t\tCanonical name: ").Append(cnameRecordSet.CanonicalName); + } + + var mxRecordSets = privateDnsZone.MxRecordSets.List(); + builder.Append("\n\tMX Record sets:"); + foreach (var mxRecordSet in mxRecordSets) + { + builder.Append("\n\t\tId: ").Append(mxRecordSet.Id) + .Append("\n\t\tName: ").Append(mxRecordSet.Name) + .Append("\n\t\tTtl (seconds): ").Append(mxRecordSet.TimeToLive) + .Append("\n\t\tRecords: "); + foreach (var mxRecord in mxRecordSet.Records) + { + builder.Append("\n\t\t\tExchange server, Preference: ") + .Append(mxRecord.Exchange) + .Append(" ") + .Append(mxRecord.Preference); + } + } + + var ptrRecordSets = privateDnsZone.PtrRecordSets.List(); + builder.Append("\n\tPTR Record sets:"); + foreach (var ptrRecordSet in ptrRecordSets) + { + builder.Append("\n\t\tId: ").Append(ptrRecordSet.Id) + .Append("\n\t\tName: ").Append(ptrRecordSet.Name) + .Append("\n\t\tTtl (seconds): ").Append(ptrRecordSet.TimeToLive) + .Append("\n\t\tTarget domain names: "); + foreach (var domainNames in ptrRecordSet.TargetDomainNames) + { + builder.Append("\n\t\t\t").Append(domainNames); + } + } + + var soaRecordSets = privateDnsZone.SoaRecordSets.List(); + builder.Append("\n\tSOA Record sets:"); + foreach (var soaRecordSet in soaRecordSets) + { + var soaRecord = soaRecordSet.Record; + builder.Append("\n\tSOA Record:") + .Append("\n\t\tHost:").Append(soaRecord.Host) + .Append("\n\t\tEmail:").Append(soaRecord.Email) + .Append("\n\t\tExpire time (seconds):").Append(soaRecord.ExpireTime) + .Append("\n\t\tRefresh time (seconds):").Append(soaRecord.RefreshTime) + .Append("\n\t\tRetry time (seconds):").Append(soaRecord.RetryTime) + .Append("\n\t\tNegative response cache ttl (seconds):").Append(soaRecord.MinimumTtl) + .Append("\n\t\tTtl (seconds):").Append(soaRecordSet.TimeToLive); + } + + var srvRecordSets = privateDnsZone.SrvRecordSets.List(); + builder.Append("\n\tSRV Record sets:"); + foreach (var srvRecordSet in srvRecordSets) + { + builder.Append("\n\t\tId: ").Append(srvRecordSet.Id) + .Append("\n\t\tName: ").Append(srvRecordSet.Name) + .Append("\n\t\tTtl (seconds): ").Append(srvRecordSet.TimeToLive) + .Append("\n\t\tRecords: "); + foreach (var srvRecord in srvRecordSet.Records) + { + builder.Append("\n\t\t\tTarget, Port, Priority, Weight: ") + .Append(srvRecord.Target) + .Append(", ") + .Append(srvRecord.Port) + .Append(", ") + .Append(srvRecord.Priority) + .Append(", ") + .Append(srvRecord.Weight); + } + } + + var txtRecordSets = privateDnsZone.TxtRecordSets.List(); + builder.Append("\n\tTXT Record sets:"); + foreach (var txtRecordSet in txtRecordSets) + { + builder.Append("\n\t\tId: ").Append(txtRecordSet.Id) + .Append("\n\t\tName: ").Append(txtRecordSet.Name) + .Append("\n\t\tTtl (seconds): ").Append(txtRecordSet.TimeToLive) + .Append("\n\t\tRecords: "); + foreach (var txtRecord in txtRecordSet.Records) + { + if (txtRecord.Value.Count() > 0) + { + builder.Append("\n\t\t\tValue: ").Append(txtRecord.Value.FirstOrDefault()); + } + } + } + + var virtualNetworkLinks = privateDnsZone.VirtualNetworkLinks.List(); + builder.Append("\n\tVirtual network links:"); + foreach (var virtualNetworkLink in virtualNetworkLinks) + { + builder.Append("\n\t\tId: ").Append(virtualNetworkLink.Id) + .Append("\n\t\tName: ").Append(virtualNetworkLink.Name) + .Append("\n\t\tReference of virtual network: ").Append(virtualNetworkLink.ReferencedVirtualNetworkId) + .Append("\n\t\tRegistration enabled: ").Append(virtualNetworkLink.IsAutoRegistrationEnabled); + } + Utilities.Log(builder.ToString()); + } + public static void Print(IRegistry azureRegistry) { StringBuilder info = new StringBuilder(); @@ -2648,7 +2768,15 @@ public static void CreateCertificate(string domainName, string pfxPath, string p ProcessStartInfo info = new ProcessStartInfo("powershell", args); string assetPath = Path.Combine(ProjectPath, "Asset"); info.WorkingDirectory = assetPath; - Process.Start(info).WaitForExit(); + Process process = Process.Start(info); + process.WaitForExit(); + + if (process.ExitCode != 0) + { + // call "Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass" in powershell if you fail here + + Utilities.Log("powershell createCert.ps1 script failed"); + } } else { diff --git a/ManageContainerRegistry.csproj b/ManageContainerRegistry.csproj index 15336f9..3a1acfc 100644 --- a/ManageContainerRegistry.csproj +++ b/ManageContainerRegistry.csproj @@ -18,15 +18,15 @@ - - + + - + diff --git a/README.md b/README.md index 38c4037..aeb3ebb 100644 --- a/README.md +++ b/README.md @@ -4,45 +4,43 @@ languages: - csharp products: - azure -- azure-container-registry -- dotnet extensions: - services: Container-Registry - platforms: dotnet -description: "Azure Container Registry sample for managing container registry." -urlFragment: getting-started-on-managing-azure-container-registry-using-c --- -# Get started managing Azure Container Registry (C#) +# Getting started on managing Azure Container Registry using C# # -Azure Container Registry sample for managing container registry. + Azure Container Registry sample for managing container registry. + - Create an Azure Container Registry to be used for holding the Docker images + - If a local Docker engine cannot be found, create a Linux virtual machine that will host a Docker engine + to be used for this sample + - Use Docker DotNet to create a Docker client that will push/pull an image to/from Azure Container Registry + - Pull a test image from the public Docker repo (hello-world:latest) to be used as a sample for pushing/pulling + to/from an Azure Container Registry + - Create a new Docker container from an image that was pulled from Azure Container Registry -- Create an Azure Container Registry to be used for holding the Docker images -- If a local Docker engine cannot be found, create a Linux virtual machine that will host a Docker engine - to be used for this sample -- Use Docker DotNet to create a Docker client that will push/pull an image to/from Azure Container Registry -- Pull a test image from the public Docker repo (hello-world:latest) to be used as a sample for pushing/pulling - to/from an Azure Container Registry -- Create a new Docker container from an image that was pulled from Azure Container Registry - -## Running this sample +## Running this Sample ## To run this sample: Set the environment variable `AZURE_AUTH_LOCATION` with the full path for an auth file. See [how to create an auth file](https://github.com/Azure/azure-libraries-for-net/blob/master/AUTH.md). -```bash -git clone https://github.com/Azure-Samples/acr-dotnet-manage-azure-container-registry.git -cd acr-dotnet-manage-azure-container-registry -dotnet build -bin\Debug\net452\ManageContainerRegistry.exe -``` + git clone https://github.com/Azure-Samples/acr-dotnet-manage-azure-container-registry.git + + cd acr-dotnet-manage-azure-container-registry + + dotnet build -## More information + bin\Debug\net452\ManageContainerRegistry.exe + +## More information ## [Azure Management Libraries for C#](https://github.com/Azure/azure-sdk-for-net/tree/Fluent) [Azure .Net Developer Center](https://azure.microsoft.com/en-us/develop/net/) -If you don't have a Microsoft Azure subscription you can get a FREE trial account [here](http://go.microsoft.com/fwlink/?LinkId=330212). +If you don't have a Microsoft Azure subscription you can get a FREE trial account [here](http://go.microsoft.com/fwlink/?LinkId=330212) + +--- -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. \ No newline at end of file