Git Basic Commands 101

This post is just a basic listing of simple git commands. These are the basics commands to start using Git, this is mostly for my own
reference.  You can download git here: https://git-scm.com/. For a complete guide on git, check out https://git-scm.com/book/en/v2

Local Repo Git Commands

 

Command

 

 

Description

 

 

Example

 

 

git init

 

 

Used to set up a directory as a Git
Repo

 

 

git init

 

 

git status

 

 

Check
the status of the existing repo branch

 

 

git
status

 

 

git branch
<branch>

 

 

Creates a branch off current
branch

 

 

git branch MyBranch

 

 

git checkout
<branch>

 

 

Switches
your repo to another branch

 

 

git
checkout MyBranch

 

 

git add
<filename>

 

 

Adds a single for to the staging
area

 

 

git add MyFile.cpp

 

 

git add .

 

 

Adds
all files in the current repo branch to staging
area

 

 

git
add .

 

 

Git commit

 

 

Commits a change to the
repo

 

 

git commit

 

 

git commit -m
‘<message>’

 

 

Commits
a change using an inline comment

 

 

git
commit -m ‘Change 3’

 

 

git commit -a -m
‘<message>’

 

 

Stages and Commits all change using inline
comment

 

 

git commit -a -m ‘Change
3’

 

 

touch
<filename>

 

 

Creates
a blank file

 

 

touch
.gitignore

 

 

git stash

 

 

Places all committed changes into a working directory
for later use.

 

 

git stash

 

 

git stash apply

 

 

Recovers
the stash back to the branch

 

 

Git
stash apply

 

 

Git Ignore file can be used to exclude files from the repo. Use pattern or file name in the “.gitignore” file. I.e. *.log.

Remote Repo Git Commands

 

Command

 

 

Description

 

 

Example

 

 

git remote

 

 

Displays the currently available remote
repos

 

 

git remote

 

 

git clone
<url>

 

 

Clones
a remote repo to your local repo

 

 

git
clone https://github.com/account/repo.git

 

 

git remote -v

 

 

Displays the repo URL

 

 

git remote -v

 

 

git fetch
<remoterepo>

 

 

Will
fetch any changes made in the remote repo since the last close or fetch. This
will not perform a merge.

 

 

git
fetch origin

 

 

git pull origin

 

 

Will fetch and merge the changes from a remote repo
into your local

 

 

git pull origin

 

 

git push <remoterepo>
<branch>

 

 

Pushes
changes from the local repo to the remote
repo

 

 

git
push origin master

 

 

git remote add <repoalias>
<cloneurl>

 

 

Creates a new local repo from a remote with an
alias

 

 

git remote add myrepo
https://github.com/account/repo.git

 

 

 

Advertisement

Azure WAF failed to remove the rule. The referenced resource was not found.

The WAF is a very nice solution, but sometimes you have strange problems. Today I had a strange one. While updating and creating rules in a WAF, I got the following error.

Error: Resource

/subscriptions/GUID/resourceGroups/waf-rg/providers/Microsoft.Network/applicationGateways/waf-01/httpListeners/HTTPS_dev-domain-com_Listener

referenced by resource

/subscriptions/GUID/resourceGroups/waf-rg/providers/Microsoft.Network/applicationGateways/waf-01/redirectConfigurations/HTTP_dev-domain-com was not found.

Please make sure that the referenced resource exists, and that both resources are in the same region.

The issue happens when I delete some rules. I had one rule that was a HTTP listener with a redirector to HTTPS listener. Once the HTTP rule was deleted, the redirector link was not removed. This created a problem as the HTTPS listener could not be deleted.

The fix was to use PowerShell to remove the redirection rule. This was not an option in the Azure Portal.

First, we get the WAF. Then use that to get the rules.

$waf = Get-AzureRmApplicationGateway -Name waf-01 -ResourceGroupName waf-rg

Get the rules and verify they match the redirect rule from the error.

Get-AzureRmApplicationGatewayRedirectConfiguration -ApplicationGateway $waf -Name HTTP_dev-domain-com

Get-AzureRmApplicationGatewayHttpListener -ApplicationGateway $waf -Name HTTPS_dev-domain-com_Listener

Next, remove the redirection configuration rule and the problem listener.


 

remove-AzureRmApplicationGatewayRedirectConfiguration -ApplicationGateway $waf -Name HTTP_dev-domain-com

Remove-AzureRmApplicationGatewayHttpListener -ApplicationGateway $waf -Name "HTTPS_dev-domain-com_Listener"

 

Finally, we update the WAF.

 


$UpdatedAppGw = Set-AzureRmApplicationGateway -ApplicationGateway $waf

Connecting to Office 365 with PowerShell

This is just s simple script for connecting to Office 365 with PowerShell.


# Import Required PowerShell Modules
# Note - the Script Requires PowerShell 3.0!

Import-Module MSOnline 

# Office 365 Admin Credentials
$CloudUsername = 'username'
$CloudPassword = ConvertTo-SecureString 'password' -AsPlainText -Force
$CloudCred = New-Object System.Management.Automation.PSCredential $CloudUsername, $CloudPassword 

# Connect to Office 365
Connect-MsolService -Credential $CloudCred

Design templates for Universal Windows Platform (UWP) apps

Microsoft has updated their design template for Windows 10 apps. The new templates are in both PowerPoint and Adobe Illustrator.

https://dev.windows.com/en-US/design/assets

PowerPoint design template

PowerPoint

This deck has everything you need to quickly mock up wireframes for UWP apps, including controls and layouts.

Windows 8.1 templates can also be found on the same site.

SQL 2014 RTM

SQL2014 is finally here. The evaluation is ready for people to start downloading. It has been release on TechNet evaluations and MSDN.

SQL 2014 Evaluation:

http://technet.microsoft.com/en-au/evalcenter/dn205291.aspx

SQL 2014 Training:

http://www.microsoftvirtualacademy.com/training-courses/mission-critical-performance-with-sql-server-2014-jump-start

Some of the key new features are;

  • In-Memory OLTP: Provides in-memory OLTP capabilities built into core SQL Server database to significantly improve the transactional speed and throughput of your database application. In-Memory OLTP is installed with the SQL Server 2014 Engine without requiring any additional actions and allows in-memory performance benefits without rewriting your database application or refreshing your hardware. In-Memory OLTP allows you to access the other rich features in SQL Server, while taking advantage of in-memory performance.
  • In-Memory Updateable ColumnStore: Provides higher compression, richer query support and updateability of the existing ColumnStore for data warehousing workloads giving you even faster load speed, query performance, concurrency, and even lower price per terabyte.
  • Extending Memory to SSDs: Seamlessly and transparently integrates solid-state storage into SQL Server by using SSDs as an extension to the database buffer pool, allowing more in-memory processing and reducing disk IO.
  • Enhanced High Availability
    • New AlwaysOn features: Availability Groups now support up to 8 secondary replicas that remain available for reads at all times, even in the presence of network failures. Failover Cluster Instances now support Windows Cluster Shared Volumes, improving the utilization of shared storage and increasing failover resiliency.
    • Improved Online Database Operations: Includes single partition online index rebuild and managing lock priority for table partition switch, reducing maintenance downtime impact.
  • Encrypted Backup: Provides encryption support for backups, on-premise and in Windows Azure.
  • IO Resource Governance: Resource pools now support configuration of minimum and maximum IOPS per volume, enabling more comprehensive resource isolation controls.
  • Hybrid Scenarios:
    • SQL Server Backup to Azure: Provides management and automation of SQL Server backups (from on-premise and Windows Azure) to Windows Azure storage.
    • AlwaysOn with Azure Secondaries: Easily add replicas in Windows Azure to on-premise Availability Groups.
    • SQL XI (XStore Integration): Supports SQL Server Database files (from on-premise and Windows Azure) on Windows Azure Storage blobs.
    • Deployment Wizard: Easily deploy on-premise SQL Server databases to Windows Azure.
  • How to update ADFS Certificate in Windows 2012 R2

    Over the last week I had to change some certificates on a few ADFS solutions. They servers were all built with internal certificates for testing, but now need production 3rd party certificates.

    The steps to change a certificate with IIS are simple, however the new ADFS no longer requires IIS.

    The following process outlines the steps to change the SSL on ADFS without IIS.

    First we need to have the correct SSL certificate. The SSL certificate must have the following;

    Valid domain name:

    The FQDN must be valid in the certificate for the ADFS site. You can use a wildcard certificate if required.

    The FQDN must be valid in the certificate for the ADFS site. You can use a wildcard certificate if required.

    Private Key:

    ADFS need to have the private key to function correctly.

    Once we have your certificate, the next step is to import it into the correct store on the machines hosting ADFS. Here I will only import the certificate into one server, this need to be done on all servers hosting ADFS.

    Open a Powershell prompt with administrator rights on the ADFS server and type the following;

    $mypwd = ConvertTo-SecureString “P@ssw0rd” -AsPlainText -Force

     

    Import-PfxCertificate –FilePath .\$ServerCertHostName.pfx cert:\localMachine\Root -Password $mypwd

     

    Example:

    PS C:\Windows\system32> $mypwd = ConvertTo-SecureString “P@ssw0rd” -AsPlainText -Force

     

     

    PS C:\Windows\system32> Import-PfxCertificate –FilePath .\$ServerCertHostName.pfx cert:\localMachine\Root -Password $mypwd 

     

    To view the certificates installed in your server’s local store, run the following commands in the Powershell prompt. Check that your certificate is there and it has the private key.

    Get-ChildItem -Path cert:\LocalMachine\my | fl -Property FriendlyName, HasPrivateKey, GetCertHashString, subject, Thumbprint, Issuer, NotAfter, NotBefore

    Example:

     

    FriendlyName  : Go Daddy Wild Card SSL

    HasPrivateKey : True

    Subject       : CN=*.domain.test, OU=Domain Control Validated

    Thumbprint    : D3561AD0AD3831BE2231B97CB40AC5EF21F5C919

    Issuer        : SERIALNUMBER=07969287, CN=Go Daddy Secure Certification Authority, OU=http://certificates.godaddy.com/repository, O=”GoDaddy.com, Inc.”,

                    L=Scottsdale, S=Arizona, C=US

    NotAfter      : 28/01/2015 5:11:40 PM

    NotBefore     : 23/01/2014 9:49:03 AM

     

    Next, we need to add the certificate to ADFS. On the ADFS server open a PowerShell prompt and run the following;

    $CertificateFriendlyName = “Go Daddy Wild Card SSL”

    $CertificateThumbprint = (Get-ChildItem -Path cert:\LocalMachine\my | Where-Object {($_.FriendlyName -eq $CertificateFriendlyName) }).Thumbprint

     Set-AdfsCertificate -CertificateType Service-Communications -Thumbprint $CertificateThumbprint

    Set-AdfsSslCertificate -Thumbprint $CertificateThumbprint

    Example:

    PS C:\Windows\system32> $CertificateFriendlyName = “Go Daddy Wild Card SSL”

    $CertificateThumbprint = (Get-ChildItem -Path cert:\LocalMachine\my | Where-Object {($_.FriendlyName -eq $CertificateFriendlyName) }).Thumbprint

    Set-AdfsCertificate -CertificateType Service-Communications -Thumbprint $CertificateThumbprint

     

    WARNING: PS0038: This action requires a restart of the AD FS Windows Service. If you have deployed a federation server farm, restart the service on every server

     in the farm.

     

    PS C:\Windows\system32> Set-AdfsSslCertificate -Thumbprint $CertificateThumbprint

     

     

    PS C:\Windows\system32>

     

    Finally, restart your ADFS service

    In the PowerShell prompt type;

    Restart-Service adfssrv

    Get-Service adfssrv

    Example:

    PS C:\Windows\system32> Restart-Service adfssrv

    Get-Service adfssrv

     

    WARNING: Waiting for service ‘Active Directory Federation Services (adfssrv)’ to start…

     

    Status   Name               DisplayName                          

    ——   —-               ———–                          

    Running  adfssrv            Active Directory Federation Services 

     

    Once all has been completed, open a browser and try with the following URL;

    https://<youradfssitefqdn>/adfs/ls/idpinitiatedsignon.aspx

    Azure/WAP: System.MethodAccessException: Attempt by security transparent method

     

    While working on a Windows Azure Pack Web Sites, I found a problem publishing MVC5 site. When you attempt to upload a MVC5 web application to Windows Azure or Windows Azure Pack you may see the error “‘System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()’ to access security critical method ‘System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)’ failed.

     

    I had to perofrm the following steps to resolve;

    1.       Install the package

    From the Package management console run the following command:

    Install-Package -Id  Microsoft.AspNet.WebHelpers

    2.       Change the deployment options to remove additional files.

    image

     

    Complete Error:

    Attempt by security transparent method ‘System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()’ to access security critical method ‘System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)’ failed.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.MethodAccessException: Attempt by security transparent method ‘System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()’ to access security critical method ‘System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)’ failed.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


    Stack Trace:

     

    [MethodAccessException: Attempt by security transparent method ‘System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()’ to access security critical method ‘System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)’ failed.]

       System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule() +44

       System.Web.WebPages.Administration.PreApplicationStartCode.Start() +22

     

    [InvalidOperationException: The pre-application start initialization method Start on type System.Web.WebPages.Administration.PreApplicationStartCode threw an exception with the following error message: Attempt by security transparent method ‘System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()’ to access security critical method ‘System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)’ failed..]

       System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +556

       System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132

       System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102

       System.Web.Compilation.BuildManager.ExecutePreAppStart() +153

       System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516

     

    [HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.WebPages.Administration.PreApplicationStartCode threw an exception with the following error message: Attempt by security transparent method ‘System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()’ to access security critical method ‘System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)’ failed..]

       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9885044

       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101

       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

     


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34009

    Errors in Windows Azure Pack after applying Update 1 to System Center 2012 R2 VMM

    After applying the Microsoft update KB http://support.microsoft.com/kb/2904712, you may see your templates and plans not updating in WAP.

    The normal steps to check are to look at the disks and templates. In WAP all templates and disks need to have an Operation System configuration.

    After the update no more new templates appear in WAP and adding a subscription to a plan fails to sync. This happens because of an updated store proc in the SQL database.

    Checking VMM you will see the following error:

    clip_image001

    VMM Error report will show the following:

    Error = 8144
    Index #0
    Source: .Net SqlClient Data Provider
    Number: 8144
    State: 2
    Class: 16
    Server: SYSSQL01
    Message: Procedure or function prc_RBS_UserRoleSharedObjectRelation_Insert has too many arguments specified.
    Procedure: prc_RBS_UserRoleSharedObjectRelation_Insert
    Line: 0

    Resolution:

    To fix the issue you need to update the sql store proc with the code from the KB 2904172. Then perform a sync on any user subscription that is not in a sync’ed state.

    TSQL code is

    use [VirtualManagerDB]
    go

    /* script starts here */
    ALTER Procedure [dbo].[prc_RBS_UserRoleSharedObjectRelation_Insert]
    (
    @ID uniqueidentifier,
    @ObjectID uniqueidentifier,
    @ObjectType int,
    @RoleID uniqueidentifier,
    @UserOrGroup varbinary (85),
    @ForeignAccount nvarchar (256),
    @IsADGroup bit,
    @ExistingID uniqueidentifier = NULL OUTPUT
    )
    AS
    SET NOCOUNT ON
    SELECT @ExistingID = [ID] FROM [dbo].[tbl_RBS_UserRoleSharedObjectRelation]
    WHERE [ObjectID] = @ObjectID AND [RoleID] = @RoleID
    AND
    — Select owner OR Select all which matches ForeignAccount or UserOrGroup OR
    — both ForeignAccount and UserOrGroup is NULL
    (([UserOrGroup] = @UserOrGroup OR [ForeignAccount] = @ForeignAccount) OR
    ([UserOrGroup] IS NULL AND @UserOrGroup IS NULL AND [ForeignAccount] IS NULL AND @ForeignAccount IS NULL))
    /* Ignore duplicate entries */
    IF (@ExistingID IS NULL)
    BEGIN
    INSERT [dbo].[tbl_RBS_UserRoleSharedObjectRelation]
    ([ID]
    ,[ObjectID]
    ,[ObjectType]
    ,[RoleID]
    ,[UserOrGroup]
    ,[ForeignAccount]
    ,[IsADGroup]
    ,[IsOwner]
    )
    VALUES
    (
    @ID,
    @ObjectID,
    @ObjectType,
    @RoleID,
    @UserOrGroup,
    @ForeignAccount,
    @IsADGroup,
    0
    )
    END
    SET NOCOUNT OFF
    RETURN @@ERROR
    /* script ends here */

    Windows Server 2012 R2 Private Cloud Virtualization and Storage Poster and Mini-Posters

    Provides a visual reference for understanding key private cloud storage and virtualization technologies in Windows Server 2012 R2.

    Download a free poster (or mini-poster) on Windows Server 2012 R2 Private Cloud Virtualization & Storage: http://spr.ly/6183evq5

    Microsoft releases System Center 2012 R2

    Microsoft has released System Center 2012 R2 to the public via MSDN and Volume licensing. Check out the following link for more details:

    http://www.microsoft.com/en-us/server-cloud/system-center/system-center-2012-r2.aspx

    “System Center 2012 R2 effectively manages the scale and performance that Windows Server 2012 R2 offers.  Building on System Center 2012, this release enables at-scale management of major Windows Server 2012 R2 capabilities, including running VM snapshots, dynamic VHDX resize, and Storage Spaces.   System Center 2012 R2 also extends software-defined networking in Windows Server 2012 R2 with provisioning and management support for a multitenant VPN gateway to enable seamless extension of datacenter capacity.  System Center 2012 R2 will continue to help you provision and manage a flexible hybrid IT environment that adapts dynamically to changing business needs, including migrating workloads to Windows Azure Virtual Machines and managing them consistently.”